Chinaunix
标题:
求助:如何用python查看文件夹的权限
[打印本页]
作者:
纵想开怀
时间:
2014-09-26 14:11
标题:
求助:如何用python查看文件夹的权限
求助:如何用python查看文件夹的权限?非常感谢
作者:
whitelotus19
时间:
2014-10-22 22:35
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
tsfname=r'/home/lotus/temp/test.py'
if os.access(tsfname,os.R_OK):
print 'file %s :readability ok' % tsfname
if os.access(tsfname,os.W_OK):
print 'file %s :writability ok' % tsfname
tsdname=r'/home/lotus/temp/ts'
if os.access(tsdname,os.R_OK):
print 'directory %s :readability ok' % tsdname
if os.access(tsdname,os.W_OK):
print 'directory %s :writability ok' % tsdname
复制代码
linux上的执行样子:
[lotus@rhel7pc1 temp]$ ls -lh
total 4.0K
-rwxrw-r--. 1 lotus lotus 446 Oct 22 22:32 test.py
dr-xrwxr-x. 2 lotus lotus 6 Oct 22 22:32 ts
[lotus@rhel7pc1 temp]$ ./test.py
file /home/lotus/temp/test.py :readability ok
file /home/lotus/temp/test.py :writability ok
directory /home/lotus/temp/ts :readability ok
[lotus@rhel7pc1 temp]$
复制代码
帮助文档有说明啊
作者:
纵想开怀
时间:
2014-11-06 10:23
非常感谢,学习了
回复
2#
whitelotus19
作者:
whitelotus19
时间:
2014-11-06 11:11
纵想开怀 发表于 2014-11-06 10:23
非常感谢,学习了回复 2# whitelotus19
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2