【发布时间】:2018-12-26 16:26:25
【问题描述】:
我想做一个简单的加法程序,但遇到如下错误: TypeError: 只能将str(不是'int')连接到str。
我不知道该怎么做,我对 Python 编码还很陌生。
def addition():
x = int(input("Please enter the first number:"))
y = int(input("Please enter the second number:"))
z = x+y
print("The sum of " +x+ " and " +y+ " gives " +z )
我希望代码返回两个输入值之和的值。
【问题讨论】:
-
推荐你看official Python tutorial,挺好的。
-
非常感谢所有帮助过的人,我知道这是一个愚蠢的问题,但我仍然是 Python 编码的新手。再次感谢...
标签: python