I get a FileNotFoundError
when trying to write to a file.
This is my code:
def save_txt_individual_tracks(track, folder, i):
f = open(folder+str(i)+'.txt','w+')
for line in track:
l=str(line[0])+','+str(line[1])+','+str(line[2])+'\n'
f.write(l)
f.close()
Which I call like so:
save_txt_individual_tracks(new,'E:/phoneTracks/'+track_name+'/',i)
Which gives me this error:
FileNotFoundError: [Errno 2] No such file or directory: 'E:/phoneTracks/TA92903URN7ff/0.txt'
I created folder phoneTracks
in E. And I am confused about open()
with mode 'w+'
, which is used to create a new file. Why do I get a FileNotFoundError
? What can I do to fix it?
I am running python3.4.3 on windows 7