51Testing软件测试论坛

标题: 新人想学自动化,刚学习简单的python遇到了问题 [打印本页]

作者: a8215196    时间: 2018-2-27 11:55
标题: 新人想学自动化,刚学习简单的python遇到了问题
from sys import argv

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)

运行后  C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe D:/python/笨方法学python/case13.py
Traceback (most recent call last):
  File "D:/python/笨方法学python/case13.py", line 3, in <module>
    script, first, second, third = argv
ValueError: not enough values to unpack (expected 4, got 1)


上网百度过 说要在命令行 运行  python  case13.py arg 1 arg2 arg 3
  但是返回报错  找不到文件
作者: 海海豚    时间: 2018-2-27 13:28
你安装的是python2,还是3?
把script, first, second, third = argv
改成script, first, second, third = argv,argv,argv,argv 试一下呢
作者: a8215196    时间: 2018-2-27 16:46
海海豚 发表于 2018-2-27 13:28
你安装的是python2,还是3?
把script, first, second, third = argv
改成script, first, second, third = ...

python 3
作者: zhu_angel    时间: 2018-2-27 16:56
可以参考下下面的地址哦~~~
https://www.zhihu.com/question/50655848/answer/122024168




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2