gpt4 book ai didi

python - linux桌面可执行python脚本

转载 作者:太空宇宙 更新时间:2023-11-04 09:02:13 54 4
gpt4 key购买 nike

我试图制作一个简单的 python 脚本可执行文件,因此用谷歌搜索了该怎么做。这是我到目前为止得到的

.桌面

[Desktop Entry]
Version=1.0
Type=Application
Name=helloworld
Comment=
Exec=./test.py
Icon=
Path=/home/xxx/Desktop
Terminal=true
StartupNotify=false

python 文件

#!/usr/bin/env python
print('hello world')

我在终端上执行了 chmod +x test.py,现在可以通过 ./test.py 在终端中执行它了

如果我双击桌面图标,我可以看到终端打开的时间很短,但很快就关闭了。

我做错了什么?

我希望桌面图标打开终端,然后显示我的 python 脚本。

谢谢

最佳答案

终端窗口将在脚本完成后关闭。你可以把

input()     # Python 3
raw_input() # Python 2

在脚本底部按回车键关闭。

关于python - linux桌面可执行python脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19068226/

54 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com