我想要发生的情况是,如果控制台打印某些内容的数量超过了500,但是现在它计算的是该数字不是数值的多少。如何计算一定数量而不是实际数量的长度?
print ("What Is The Current Distance In Meters?")
distance = input()
if len (distance) >= 500:
(print) ("Thanks")
我想要发生的情况是,如果控制台打印某些内容的数量超过了500,但是现在它计算的是该数字不是数值的多少。如何计算一定数量而不是实际数量的长度?
print ("What Is The Current Distance In Meters?")
distance = input()
if len (distance) >= 500:
(print) ("Thanks")
您需要先距离转换成一个数字,然后用比运营商>
更大,所以你的代码变成:
print ("What Is The Current Distance In Meters?")
distance = input()
if int(distance) > 500 :
print ("Thanks")
希望我帮助!
非常感谢你<3 –
input()
始终是一个字符串 - 你可能想distance = int(input())
'INT(距离)'? –
为什么你在'print'中加括号? – user2357112