yangbin990
yangbin990

Reputation: 93

Python File IO failure with specific extension "html"

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

Error Screen Shot

All people spends time would be very appreciated.

Upvotes: 2

Views: 44

Answers (3)

Fabio Lamanna
Fabio Lamanna

Reputation: 21552

Try using:

with open('abc.html', 'r+') as f:
    f.write('abc')

Upvotes: 1

yangbin990
yangbin990

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

X-Mann
X-Mann

Reputation: 327

The error says Permission denied. Make sure you have permission to write to the file.

Upvotes: 0

Related Questions