这是我的代码:
N_str = input("Input a value: ")
while True:
i=''
if N_str.isdigit and N_str.find('.')==-1:
i=N_str
if int(i)>0:
print(i)
break
else:
N_str = input("Input a value: ")
else:
N_str = input("Input a value: ")
如果输入‘x’就会显示ValueError:invalid literal for int() with base 10: 'x'
但是‘x’在第一个N_str.isdigit不应该就判定为False吗?然后跑else语句吗?
刚刚接触python,辛苦解答一下