我一直在学习和消除对 pythons 的一些误解sys.argv
。当我在 bash 中从命令行传递不同的字符时,我注意到:
script.py
import sys
def test(x):
return x
print test(sys.argv)
>>>python script.py [first, second, third]
将打印:
['script.py', '[first,', 'second,', 'third]']
和
>>>python script.py {first, second, third}
['script.py', '{first,','second,','third}']
但:
>>>python script.py (first,second,third)
bash: syntax error near unexpected token `('
这是python还是bash,也许两者兼而有之?有什么理由吗?