python查看某一个文件/程序是否是可执行的
2011-06-15 10:53
513 查看
通过os.access(filename,mode):
s.access(path, mode)¶
Use the real uid/gid to test for access to path. Note that most operations
will use the effective uid/gid, therefore this routine can be used in a
suid/sgid environment to test if the invoking user has the specified access to
path. mode should be F_OK to test the existence of path, or it
can be the inclusive OR of one or more of R_OK, W_OK, and
X_OK to test permissions. Return True if access is allowed,
False if not. See the Unix man page access(2) for more
information.
举例:
os.access(r"C:\Windows\system32\at.exe",os.X_OK)
#使用X_OK,来判断是否是可执行的.
s.access(path, mode)¶
Use the real uid/gid to test for access to path. Note that most operations
will use the effective uid/gid, therefore this routine can be used in a
suid/sgid environment to test if the invoking user has the specified access to
path. mode should be F_OK to test the existence of path, or it
can be the inclusive OR of one or more of R_OK, W_OK, and
X_OK to test permissions. Return True if access is allowed,
False if not. See the Unix man page access(2) for more
information.
举例:
os.access(r"C:\Windows\system32\at.exe",os.X_OK)
#使用X_OK,来判断是否是可执行的.
相关文章推荐
- python程序2(递归查找某一个文件夹下所有的文件是否含有某个特定的字符串,并打印该文件名)
- 每天一个python小程序 2使用python.MySQLdb执行数据库操作
- Python写的一个收集文件的小程序
- 用Pyinstaller把Python3.4程序打包成可执行文件exe
- Linux操作系统的简单指令及如何使用vim编写一个程序,然后使用gcc查看【预处理】、【编译】、【汇编】、【链接】各阶段文件的内容。
- windows下使用cx_freeze将Python程序打包成exe可执行文件
- Python:一个小小程序,如何分析unix是否安装了某个命令
- 9.11练习:文件访问,写一个逐页显示文本文件的程序,提示输入一个文件名,每次显示文本文件的25行,暂停并向用户提示“按任意键继续”,按键后继续执行。
- 1.2.在linux环境实践,使用vim编写一个程序,然后使用gcc查看【预处理】、【编译】、【汇编】、【链接】各阶段文件的内容。并熟悉相关指令。
- Python: 判断一个路径是否存在,判断一个路径是文件还是目录,创建路径,创建文件, 删除路径,删除文件
- Linux下如何查看一个文件是否拥有软链接或硬链接文件?
- python 将python程序编译成可执行文件
- Python小程序实例一(一个数字是否为素数)
- Python程序打包成exe可执行文件
- 判断本地系统目录下是否存在XML文件,如果不存在就创建一个XMl文件,若存在就在里面执行添加数据
- Python: Ubuntu14下用PyInstaller打包.py成一个单独的可执行文件_20160701_七侠镇莫尛貝
- 判断ShellExecute函数是否执行完一个程序的方法
- HDFS设计思路,HDFS使用,查看集群状态,HDFS,HDFS上传文件,HDFS下载文件,yarn web管理界面信息查看,运行一个mapreduce程序,mapreduce的demo
- 将Python程序打包成可执行文件或service
- Linux/shell命令的实际应用——ldd查看可执行程序依赖的库文件