| | |
AttributeError: 'str' object has no attribute 'insert'
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
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 |
advanced aliased bash beginner bits calling casino changecolor class clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically events examples external file float format frange function google gui hints homework i/o iframe import info input java line linux list lists loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame pygtk python random rational raw_input recursion return scrolledtext signal singleton skinning stderr string strings subprocess table tails terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop windows word wxpython





