37,743
社区成员




while not s.isdigit() and count == None:
s=raw_input('not a number, please try again: ')
if float(s) < 0:
continue
if abs(int(float(s))) < abs(float(s)): #比较绝对值,可以区分负整数和负的浮点数
continue
count = int(float(s))
s=raw_input('input your count: ')
while not s.isdigit() :#判定输入的是否是数字(整数或者浮点)
s=raw_input('not a number, please try again: ')
#数字先转浮点再转count取整数部分,可以去掉浮点的小数部分
count = int(float(s))
------------------
tag = 0
while tag == 0:
try:
count = int(input("input your count:"))
tag = 1
except:
print("不是整数")