开发者社区> 问答> 正文

在python3中用argv出错? 400 报错

在python3中用argv出错? 400 报错

在python3.3.2中输入以下代码:

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)

运行出错:

Traceback (most recent call last):
  File "D:\Exercise\ex13.py", line 3, in <module>
    script, first, second, third = argv
ValueError: need more than 1 value to unpack

请问错在哪里?

 

展开
收起
爱吃鱼的程序员 2020-05-29 19:50:01 445 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    我在2.7上运行成功的。######

    你得保存成文件

    然后运行的时候加上足够的参数:

    python Ex13.py 1 2 3

    2020-05-29 19:50:03
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Python系列直播第一讲——Python中的一切皆对象 立即下载
From Python Scikit-Learn to Sc 立即下载
Python 脚本速查手册 立即下载