📜  如何将 python 输入转换为 int - Python 代码示例

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

代码示例2
# 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}')