| | |
AttributeError: 'str' object has no attribute 'insert'
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
I'm fairly new to python and object oriented programming in general, so I'm having a little trouble figuring out why this doesn't work
this is the error I'm getting for the code below:
Error: 'str' object has no attribute 'insert'
this is the error I'm getting for the code below:
Error: 'str' object has no attribute 'insert'
Python Syntax (Toggle Plain Text)
filetolist = FileReadToList("test.txt") print filetolist[0] def FileCountLines(s_filename): f = open(s_filename) filestring = f.read() count = operator.countOf(filestring, "\n") file.close(f) return count def FileReadToList(s_filename): f = open(s_filename) count = FileCountLines(s_filename) filestring = f.read() filestring.insert(0,count) file.close(f) return filestring
Last edited by MaQleod; Apr 5th, 2009 at 11:33 pm.
•
•
Join Date: Mar 2007
Posts: 110
Reputation:
Solved Threads: 31
Change to
-BV
Python Syntax (Toggle Plain Text)
filestring = f.read()
Python Syntax (Toggle Plain Text)
filestring = f.readlines()
-BV
![]() |
Similar Threads
- Threading Module confusion (Python)
Other Threads in the Python Forum
- Previous Thread: A Beginner's Question
- Next Thread: Taking a variable out of a Tkinter GUI
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment avogadro backend beginner binary book builtin calculator character code converter countpasswordentry curved customdialog dan08 dictionaries dictionary dynamic examples exe file float format function gnu graphics gui heads homework import inches input java launcher library line lines linux list lists loop mouse mysql mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame pysimplewizard python random recursion redirect scrolledtext software statictext statistics string strings sum table terminal text textarea thread threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wordgame write wxpython xlib





