Friday, December 30, 2016

Make file read-only in Python

If you want to make file read-only:

import os
from stat import S_IREAD

os.chmod('path/to/file.txt', S_IREAD)


If you want to make file writeable:

import os
from stat import S_IWRITE

os.chmod('path/to/file.txt', S_IWRITE)


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.