python查看某一个文件/程序是否是可执行的
通过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,来判断是否是可执行的.