如何使Shebang能够在python3和python3.5之间选择正确的Python解释器

如何使Shebang能够在python3和python3.5之间选择正确的Python解释器,第1张

如何使Shebang能够在python3和python3.5之间选择正确的Python解释器

无需引入单独的shell和python脚本,单个文件可以兼而有之

用以下顺序替换您的shebang行:

#!/bin/sh# Shell commands follow# Next line is bilingual: it starts a comment in Python, and is a no-op in shell""":"# Find a suitable python interpreter (adapt for your specific needs) for cmd in python3.5 python3 /opt/myspecialpython/bin/python3.5.99 ; do   command -v > /dev/null $cmd && exec $cmd  "$@"doneecho "OMG Python not found, exiting!!!!!11!!eleven" >2exit 2":"""# Previous line is bilingual: it ends a comment in Python, and is a no-op in shell# Shell commands end here# Python script follows (example commands shown)import sysprint ("running Python!")print (sys.argv)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5632131.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存