了解Python中的参数变量

时间:2019-02-13 10:56:38

标签: python python-3.x

最近在Python脚本中,我一直使用argv作为“参数变量”,如下面的代码块所示:

# sys is a module and this phrase just says to get the argv feature from that package
from sys import argv

# Take whatever is in argv, unpack it, and assign it to all of these variables on the left in order
script, input_file = argv

下面的两行是否等效于创建“参数变量”-为什么在这种情况下仅import sys而不是from sys import argv

import sys
script, input_file = sys.argv

0 个答案:

没有答案