python怎么判断变量是否为数字

2025-04-09 08:57:06
推荐回答(2个)
回答1:

if isinstance(1,(int,float)):
print('YES')
else:
print('NO')

回答2:

isinstance(5, int)