为什么我不能在python中比较str和int

时间:2019-06-20 08:50:56

标签: python

这是我的代码:

set ASPNETCORE_ConnectionStrings__Database=test

这是我的错误结果:

launchSettings.json

这里发生了什么事?

1 个答案:

答案 0 :(得分:1)

尝试一下:作为解决方案; 我已经更新了您的代码,以仅考虑年龄类型

name = input("What's your name? ")
print("Nice to meet you " + name + "!")
while True:
    try:
        age = int(input("Your age? "))
        break
    except Exception as e:
        print("please enter a valid age")
print("So, you are already " + str(age) + " years old, " + name + "!")

if age > 50:
   print ("you are to old thx ")

else:
   print ("nice age using your apportunity ")