# 在linux环境执行的
import os,stat
files = [name for name in os.listdir('.') if name.endswith(('.sh','.py'))] # 获取本目录以sh,py结尾的文件
print(files)
for f in files:
# os.chmod 修改权限
# os.stat(f).st_mode 文件的权限
# stat.S_IXUSR 对于拥有者执行的权限
os.chmod(f,os.stat(f).st_mode | stat.S_IXUSR)
python3 50个练习例子之linux环境下给文件增加可执行权限
最新推荐文章于 2024-10-26 15:31:11 发布