Answers for "python remove read only file"

1

python remove read only file

import os
    import stat
    def rmv_rof(file_name):
        '''Remov Read Only Files'''
        if os.path.exists(file_name):
            os.chmod(file_name, stat.S_IWRITE)
            os.remove(file_name)
        else:
            print('The file does not exist.')
    rmv_rof('file_name_here')
Posted by: Guest on May-05-2021

Python Answers by Framework

Browse Popular Code Answers by Language