Python 如何解决此错误:TypeError:无法将“int”对象隐式转换为str

Python 如何解决此错误:TypeError:无法将“int”对象隐式转换为str,python,Python,input enter:返回字符串,您不能按照错误提示添加字符串和int 必须先将其转换为int类型,然后才能 >>> g = input ("enter:") enter: 50 >>> g + 100 Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> g + 100 TypeError: Can't convert 'i

input enter:返回字符串,您不能按照错误提示添加字符串和int

必须先将其转换为int类型,然后才能

>>> g = input ("enter:")
enter: 50 
>>> g + 100
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    g + 100
TypeError: Can't convert 'int' object to str implicitly
>>> 

为什么要转换int类型?请解释我,我不是专家,在我的考试中尝试一些简单的代码是int类型的构造函数,所以结果你会得到数值,所以这个int是正确的还是有其他方法?这是很多其他方法,但这是最简单的
int(g) + 100