请帮我写一个python 给目录写入权限的代码
时间: 2024-04-29 16:24:34 浏览: 81
python检查目录文件权限并修改目录文件权限的操作
Sure, here's an example Python code that adds write permission to a directory:
```python
import os
# Path of directory to be given write permission
directory_path = "/path/to/directory"
# Get the current permissions of the directory
permissions = os.stat(directory_path).st_mode
# Add write permission to the directory
os.chmod(directory_path, permissions | stat.S_IWUSR)
print("Write permission has been added to the directory.")
```
Note that you may need to run this code with root privileges to modify the permissions of certain directories.
阅读全文