【Python】python输入的另一种方法
今日所学:
1.用argv的方法给脚本输入变量。现在脚本(.py文件)中打入下面这些代码。
eg.【
from sys import argv # 固定的,python里传送sys模块给脚本 script, first, second, third = argv #定义四个参数 print "The script is called:", script print "Your first variable is:", first print "Your second variable is:", second print "Your third variable is:", third
】
2.
【
prompt = '>'
likes = raw_input(prompt)
print likes
】
运行结果:>eminem
eminem
然后再在打开cmd打开这个文件运行。格式就是....(所在路径)ex13.py first 2nd 3rd (这就是之前定义的四个参数)
---------------------------------------------------------------------------------------------------------------------------------------------------
【Remember that an important skill is paying attention to details.】
【 Zork and Adventure】
【you have to run it right on the command line】 >> 对于今天所学的!!!
感谢阅读,一起努力呗!