gpt4 book ai didi

python - 在 os x Lion 上运行 python 程序

转载 作者:行者123 更新时间:2023-11-28 21:26:19 26 4
gpt4 key购买 nike

我可以在终端中正常使用 python 3,但我不知道如何让终端运行我用 python 3 编写的程序。

我需要做什么才能将 .py 文件扩展名与终端的 python3.2.3 而不是 python2.7.1 相关联

我正在使用 textwrangler 作为我的文本编辑器,但如果它可以运行,我会很乐意使用任何编辑器,尽管我不认为这是我的问题,因为 idle 也不起作用并且它没有行号要么。

亲切的问候

罗布

最佳答案

python3 hashbang 添加到脚本的开头:

#!/usr/bin/env python3
# do stuff

然后,您可以使脚本可执行并运行它:

chmod +x script.py
./script.py

关于python - 在 os x Lion 上运行 python 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13102552/

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