我正在学习 python 教程。我完全输入了教程中的内容,但它无法运行。我认为问题是教程使用了 Python 2,而我使用的是 Python 3.5。例如,教程在打印后不使用括号,我必须使用,它使用 raw_input,而我只使用输入。
这就是我想要运行的-
def sumProblem(x, y):
print ('The sum of %s and %s is %s.' % (x, y, x+y))
def main():
sumProblem(2, 3)
sumProblem(1234567890123, 535790269358)
a, b = input("Enter two comma separated numbers: ")
sumProblem(a, b)
main()
这是我收到的错误:
ValueError: too many values to unpack (expected 2)
如果我只输入两个没有逗号的数字,它将连接它们。我试图更改为整数,但它给出了这个错误:
ValueError: invalid literal for int() with base 10:
当我在这里搜索时,答案似乎不适用于我的问题,他们涉及更多或我不明白。
红颜莎娜
相关分类