Today in this article we will learn about the python os.chown() method. In the next article we will introduce the python os.chown() method, chown and chmod Looks very similar, but they are two completely different methods. I will introduce the chown() method in the next article.
Overview
The os.chown() method is used to change the file owner. If it is not modified, it can be set to -1. You need superuser permissions to perform permission modifications. operate.
Only supports use under Unix.
Grammar
os.chown(path, uid, gid);
Parameters
Example
The following example demonstrates the use of the lchmod() method:#!/usr/bin/python # -*- coding: UTF-8 -*- import os, sys # 假定 /tmp/foo.txt 文件存在. # 设置所有者 ID 为 100 os.chown("/tmp/foo.txt", 100, -1) print "修改权限成功!!"
修改权限成功!!
Python tutorial column on the php Chinese website.
The above is the detailed content of What is the python os.chown() method? What does it do?. For more information, please follow other related articles on the PHP Chinese website!