Alright I have a method:
def manage_file(current_city):
read_f = open('temp.txt', 'rb')
dict = pickle.load(read_f)
read_f.close()
dict[time.strftime('%Y/%m/%d %H:%M:%S ') + current_city] = current_temp
write_f = open('temp.txt', 'wb')
pickle.dump(dict, write_f)
return dict
For some reason I am getting an error :
line 21, in manage_file write_f = open('temp.txt', 'wb') IOError: [Errno 13] Permission denied: 'temp.txt'
Anyone familiar with this, and know a solution?
As Jan Vlcinsky comments, you don't seem to have write permissions to that file. If you have sufficient permissions to change file permissions (may require that you know the super user password), you can change file permissions with chmod
in a terminal on a linux machine or on a mac.
You would:
cd
to the correct directorychmod abc temp.txt
a, b, c should be numbers representable in binary between 000 and 111 (so numbers between 0 and 7). Each digit of the binary representation encodes read, write, and execute privileges respectively. a is for the file owner's permissions, b is for the file's group permissions, and c is for everyone else's permissions.
So you could do chmod 755 temp.txt
to give the file owner permission to read, write and execute (7 = 111) and give everyone else read and execute (5 = 101) permissions.