求助:如何用python查看文件夹的权限
求助:如何用python查看文件夹的权限?非常感谢 #!/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上的执行样子:$ 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
$ ./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
$ 帮助文档有说明啊 非常感谢,学习了回复 2# whitelotus19
纵想开怀 发表于 2014-11-06 10:23 static/image/common/back.gif
非常感谢,学习了回复 2# whitelotus19
:emn35:
页:
[1]