您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何授予Linux中所有Python脚本可执行权限?

如何授予Linux中所有Python脚本可执行权限?

以root权限运行以下命令:

find /your/path/ -type f -name "*.py" -exec chmod u+x {} \;

chmod如果您是.py文件的所有者,则无需以root用户身份运行。

编写脚本来解决这个问题。

#!/bin/bash
if [ -f "$1" ]
then
geany "$1" # You Could also use xdg-open if you set geany to open .py files
else
cp /path/to/python/startup/template "$1" # You may omit this if you don't have a default template
chmod u+x "$1"
geany "$1"
fi

将脚本另存为,pycreator例如/usr/bin/,然后说

chown root:root /usr/bin/pycreator
chmod +x-w /usr/bin/pycreator

要使用创建新脚本pycreator,请执行

pycreator calculator.py
python 2022/1/1 18:25:12 有340人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶