在 Python 脚本的第一行使用 #!/usr/bin/env 有什么作用
#!/usr/bin/env 告诉计算机用什么程序执行该脚本。
001、测试两个程序
[root@pc1 test]# ls ## 两个测试程序 test2.py test.py [root@pc1 test]# cat test.py ## 程序1 print('hello world') [root@pc1 test]# cat test2.py ## 程序2 #!/usr/bin/env python print('hello world') [root@pc1 test]# python test.py ## 运行方式1 hello world [root@pc1 test]# python test2.py ## 运行方式1 hello world [root@pc1 test]# ./test.py ## 运行方式2 ./test.py: line 1: syntax error near unexpected token `'hello world'' ./test.py: line 1: `print('hello world')' [root@pc1 test]# ./test2.py ## 运行方式2 hello world [root@pc1 test]# python --version Python 2.7.5
。
来源:
01、https://mp.weixin.qq.com/s?__biz=MzI4NDUzNjk1Nw==&mid=2247487773&idx=1&sn=0cd2fc717ef2ad94d2af9d5b8f2d23d2&chksm=ebf8a80fdc8f21191be195d9844234cafd98cd43437b357d2d2cd00c1dd7bf56cd10705c7db9#rd
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2022-10-31 >chr1 <_io.TextIOWrapper name='result.fa' mode='w' encoding='UTF-8'>
2022-10-31 python 中实现将两个列表合并为字典
2022-10-31 linux 中实现文本的按列反转
2021-10-31 R语言中矩阵运算
2021-10-31 R语言实现计算两个向量的协方差、标准差、皮尔逊相关系数
2021-10-31 R语言统计 plink格式数据样本缺失率
2021-10-31 linux shell 统计plink格式样本缺失率