- 论坛徽章:
- 0
|
- #!/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]$
复制代码 帮助文档有说明啊 |
|