python write data to file with permissions

Solutions on MaxInterview for python write data to file with permissions by the best coders in the world

showing results for - "python write data to file with permissions"
Lucia
01 Jan 2018
1#!/usr/bin/env python3
2import stat
3import os
4path = 'outfile.txt'
5with open(path, 'w') as fh:
6    fh.write('blabla\n')
7st = os.stat(path)
8os.chmod(path, st.st_mode | stat.S_IWOTH)