|
|
2009-01-14
, 01:56
|
|
Posts: 1,101 |
Thanked: 1,184 times |
Joined on Aug 2008
@ Spain
|
#2
|
|
|
2009-01-14
, 02:15
|
|
|
Posts: 903 |
Thanked: 632 times |
Joined on Apr 2008
|
#3
|
|
|
2009-01-14
, 08:41
|
|
|
Posts: 3,404 |
Thanked: 4,474 times |
Joined on Oct 2005
@ Germany
|
#4
|

fd = open("myfile", "a")
fd.write("some text")
fd.close()
| The Following User Says Thank You to pycage For This Useful Post: | ||
|
|
2009-01-14
, 19:48
|
|
|
Posts: 903 |
Thanked: 632 times |
Joined on Apr 2008
|
#5
|
Dive into Python is excellent work but really confusing stuff.
You can use mode "a" to append:
Code:fd = open("myfile", "a") fd.write("some text") fd.close()
I'm trying to append data to a file, but the .append object doesn't work (.write does, though):
Traceback (most recent call last): File "/home/user/scripts/battery_check/battery_check.py", line 20, in <module> logfile.append(add_time) AttributeError: 'file' object has no attribute 'append'Any idea what is wrong?