【发布时间】:2019-01-04 14:50:11
【问题描述】:
我试图使用 sys.argv[0] 来获取脚本的名称,但它什么也没返回。我猜那是因为没有将脚本名称传递给 Python 解释器,但我不知道如何修复它。
我的代码:
import sys
print ("This is the name of the script: ", sys.argv[0])
sys.argv[0]
输出:
>>> import sys
>>> print ("This is the name of the script: ", sys.argv[0])
This is the name of the script:
>>> sys.argv[0]
''
谢谢
【问题讨论】:
-
没有办法修复它,因为没有什么可修复的?你希望它返回什么?
标签: python read-eval-print-loop argv sys