View Single Post
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#1
So I'm working on a fairly simple python script, but have run into a problem.

I'm trying to append data to a file, but the .append object doesn't work (.write does, though):

Code:
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'
My code is this:

Code:
   logfile = open(date_stamp, 'w')
   logfile.append(add_time)
Where date_stamp and add_time are predefined variables.

Any idea what is wrong?