Answers for "python write data to file with permissions"

0

python write data to file with permissions

#!/usr/bin/env python3
import stat
import os
path = 'outfile.txt'
with open(path, 'w') as fh:
    fh.write('blabla\n')
st = os.stat(path)
os.chmod(path, st.st_mode | stat.S_IWOTH)
Posted by: Guest on August-11-2020

Python Answers by Framework

Browse Popular Code Answers by Language