【发布时间】:2020-06-26 05:38:00
【问题描述】:
我是一名初级程序员,正在学习 Python。 我正在编写一些简单的程序来学习基础知识。 昨天,我试图用“if-else 语句”编写一个程序,但由于这个错误它不起作用:
-TypeError: '>=' 在 'str' 和 'int' 的实例之间不支持。-
什么意思?
下面是我正在使用的代码:
print(' Insert a value to "a": ')
a= input()
if a >= 1:
print('G') # random letter
【问题讨论】:
-
该错误清楚地表明您正在尝试将字符串与您无法在 python 中执行的整数进行比较!
-
那么,“我的字符串大于或等于 1”是什么意思?
-
欢迎来到 SO!请阅读minimal reproducible example 并相应地编辑您的帖子
-
trying to write a program whit "if-else statement", but it don't work。我们怎么知道您尝试了哪些代码。请贴代码sn-p让我们理解。 -
现在看看。
标签: python string int typeerror