numberstoadd = input("What is the first number you want to add? ")
numbertoadd = input("What do you want to add to it? ")
sum = numbertoadd + numberstoadd
print sum
number_1 = int(raw_input("What is the first number you want to add? "))
number_2 = int(raw_input("What do you want to add to it? "))
sum = number_1 + number_2
print sum
您需要将输入
string
s转换为int
s在Python 2中,
input
将eval
类型化文本并返回整数,而在Python 3下,input
只返回包含类型化文本的string
(相当于python2中的raw_input
)。有关Python版本2.x&3.x之间的其他更改,请参见此链接
http://docs.python.org/dev/whatsnew/3.0.html
相关问题 更多 >
编程相关推荐