Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #python how to change File Attributes (Read and Write)
- #taken from http://techarttiki.blogspot.com/2008/08/read-only-windows-files-with-python.html
- import os, stat
- myFile = r'TestFile.txt'
- fileAtt = os.stat(myFile)[0]
- if (not fileAtt & stat.S_IWRITE):
- # File is read-only, so make it writeable
- os.chmod(myFile, stat.S_IWRITE)
- else:
- # File is writeable, so make it read-only
- os.chmod(myFile, stat.S_IREAD)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement