【发布时间】:2016-09-19 06:19:23
【问题描述】:
我需要将现有文件夹的权限更改为“未经许可”——这意味着它们不能被读/写。
有没有办法在 python (windows) 中做到这一点?
【问题讨论】:
标签: python python-2.7 permissions chmod
我需要将现有文件夹的权限更改为“未经许可”——这意味着它们不能被读/写。
有没有办法在 python (windows) 中做到这一点?
【问题讨论】:
标签: python python-2.7 permissions chmod
是的,您可以使用 os.chmod 来完成,但您只能在 windows 中设置 stat.S_IWRITE 和 stat.S_IREAD https://docs.python.org/2/library/os.html
【讨论】:
使用 os.chmod()。 os.chmod(路径, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
【讨论】: