📜  以 10 为基数的 int() 的无效文字 python 代码示例

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

代码示例1
#another way is to check if the entered number isdigit()
#that way you will ensure unhandled exception incase of erroneus data

number= input("What is your weight:")
if number.isdigit():
    kilos=int(float(number))
    print ("The weight of the person is:" + str(kilos))
else:
    print("Error - Please enter a proper weight")