学习python第(n’)天——我在看笨办法学python(参数,解包,变量)

这是所有的语言

from sys import argv
#read the WYSS section for how to run this.
#ex3.py是参数。
# argv 是参数变量(argument variable)。
#import的作用是调用参数特性,这些导入的特性称为模块(module)或库(library)。

script, first, second, third = argv
#这是一个解包(unpack)过程。

print ("The script is called:", script)
print ("Your first variable is:", first)
print ("Your second variable is:", second)
print ("Your third variable is:", third)
# python ex2.py first second third(遇到argv,运行时得千万注意)

#这些是《笨办法学编程》page.38-40的内容。

这是所有的运行结果

 

PS C:\Users\HH\lpthw> python ex2.py first second third
The script is called: ex2.py
Your first variable is: first
Your second variable is: second
Your third variable is: third
PS C:\Users\HH\lpthw>

 

上一篇:线性表


下一篇:XForms 行为(Actions)