Python os.chown () method
Python OS file / directory methods
Outline
os.chown () method is used to change the owner of the file, if you can not modify the set to -1, you need superuser privileges to execute permissions to modify operations.
Supported only under Unix.
grammar
chown () method syntax is as follows:
os.chown(path, uid, gid);
parameter
path - set the permissions of the file path
uid - their user ID
gid - user group ID
return value
This method has no return value.
Examples
The following example demonstrates lchmod () method of use:
#!/usr/bin/python # -*- coding: UTF-8 -*- import os, sys # 假定 /tmp/foo.txt 文件存在. # 设置所有者 ID 为 100 os.chown("/tmp/foo.txt", 100, -1) print "修改权限成功!!"
The above program output is:
修改权限成功!!