您的位置:首页 > 编程语言 > Python开发

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,来判断是否是可执行的.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐