📜  如何在python代码示例中获取int输入

📅  最后修改于: 2022-03-11 14:45:39.162000             🧑  作者: Mango

代码示例4
# Any input taken by python is always taken as a string.
# To convert it to an integer, we have to wrap input() in int(). Example:

num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number: "))
total = num1 + num2
print(f'Sum: {total}')