Python 为什么我的值不是类型而不是字符串?

Python 为什么我的值不是类型而不是字符串?,python,Python,此错误显示为: Exception has occurred: TypeError int() argument must be a string, a bytes-like object or a number, not 'NoneType' File "C:\Users\Asus\Desktop\pro6.py", line 3, in <module> print(int(a)) 删除第二条语句中的“打印”: x=int(input()) a=(str(x%5)+str(x%

此错误显示为:

Exception has occurred: TypeError
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
File "C:\Users\Asus\Desktop\pro6.py", line 3, in <module>
print(int(a))
删除第二条语句中的“打印”:

x=int(input())
a=(str(x%5)+str(x%100//10)+str(x//100))
print(int(a)*2)

您不应该将“print”赋值给变量。

函数返回
None
。你想干什么?为什么你不能只做
a=(x%5)*100+(x%100//10)*10+x//10
print
不返回任何值。@某个程序员我想反转3位数字并乘以2。这个代码可以反转数字,但不能乘以2。没问题,另外,正如一些程序员提到的,在一个变量中,你不需要从int转换为str。除非出于某种原因必须转换为str,否则取int并返回int。别忘了投票,我需要这些代表点:)
x=int(input())
a=(str(x%5)+str(x%100//10)+str(x//100))
print(int(a)*2)