知识点:
- from sys import argv // 把 系统模块 导入 参数变量 中
- 解包参数,script , one , two , three
1 from sys import argv # 把 系统模块 导入 参数变量 ,必须写argv 2 3 script, first, second, third = argv # 把 argv 参数变量解包(argv字母不能改),依次赋值给四个变量,四个变量名可任意 4 5 print("The script is called:",script) # 这个脚本被调用,ex13.py 6 print("Your first variable is:",first) # 你的第一个变量是XX 7 print("Your second variable is:",second) # 你的第二个变量是XX 8 print("Your third variable is:",third) # 你的第三个变量是XX
PS C:\Users\Administrator\lpthw> python ex13.py apple orange banana The script is called: ex13.py Your first variable is: apple Your second variable is: orange Your third variable is: banana
标签:13,变量,script,argv,解包,variable,习题,Your From: https://www.cnblogs.com/luxiaoli/p/17740902.html