📜  python 将数据写入具有权限的文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:33.219000             🧑  作者: Mango

代码示例1
#!/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)