线路怎么了6:
name = (input('Hi, please enter your name '))
dob = int(input('Hi please enter your DOB '))
today = int(input("Hi please enter today's date "))
future = int(today + 5)
diff = str(future - dob)
print ('Hi ' + name + 'in the year of ' + future + 'you will turn ' + diff)
我总是出错:
^{pr2}$你们一般怎么调试?我是编程新手。有没有办法知道它到底想把绳子放在哪里?在
future
是一个整数,因此不能与字符串连接。您可以这样做:或将
^{pr2}$int
转换为str
示例:
^{3}$输出:
示例:
输出:
Python无法自动将整型变量转换为字符串。在
您需要将
future
变量显式转换为str
类型,如下所示:相关问题 更多 >
编程相关推荐