Reputation: 93
I had very weird issue using Python (I am very new to Python). I can write to a file successfully, however would be failed if the filename has extension ".html".
Screen shot below is the error, I am very sure the same name file doesn't exist. If I change ".html" to ".tml", then the code would be working. My OS is windows 8. Python version is 2.7.9
All people spends time would be very appreciated.
Upvotes: 2
Views: 44
Reputation: 21552
Try using:
with open('abc.html', 'r+') as f:
f.write('abc')
Upvotes: 1
Reputation: 93
The root cause is unknown and but today I turned on the PC again and run the script and it works. It shames it just worked after PC restarted.
Thanks, Fabio and DhaLee
Upvotes: 0
Reputation: 327
The error says Permission denied
. Make sure you have permission to write to the file.
Upvotes: 0