Python os.lchown() 方法
Python 教程
· 2019-02-03 23:12:11
概述
os.lchown() 方法用于更改文件所有者,类似 chown,但是不追踪链接。
只支持在 Unix 下使用。
语法
lchown()方法语法格式如下:
os.lchown(path, uid, gid)
参数
path -- 设置权限的文件路径
uid -- 所属用户 ID
gid -- 所属用户组 ID
返回值
该方法没有返回值。
实例
以下实例演示了 lchown() 方法的使用:
#!/usr/bin/python # -*- coding: UTF-8 -*- import os, sys # 打开文件 path = "/var/www/html/foo.txt" fd = os.open( path, os.O_RDWR|os.O_CREAT ) # 关闭打开的文件 os.close( fd ) # 修改文件权限 # 设置文件所属用户 ID os.lchown( path, 500, -1) # 设置文件所属用户组 ID os.lchown( path, -1, 500) print "修改权限成功!!"
执行以上程序输出结果为:
修改权限成功!!
点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html
Introduction to Algorithms, 3rd Edition
Thomas H. Cormen、Charles E. Leiserson、Ronald L. Rivest、Clifford Stein / The MIT Press / 2009-7-31 / USD 94.00
Some books on algorithms are rigorous but incomplete; others cover masses of material but lack rigor. Introduction to Algorithms uniquely combines rigor and comprehensiveness. The book covers a broad ......一起来看看 《Introduction to Algorithms, 3rd Edition》 这本书的介绍吧!