<分区> 分区>
我试图使用 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]
''
谢谢
