PYTHON 中判断大于小于时为什么在判断输入数字大于需要的数字时其之后的代码无法运行?

2025-02-25 00:05:09
推荐回答(3个)
回答1:

没问题呀,你看一下你的换行格式有没有问题,实在不知道发源码

回答2:

def getInt(prompt, limit=(0, None)):
while True:
try:
x = int(input(prompt))
if limit[0] is not None and x < limit[0]:
continue
if limit[1] is not None and limit[1] < x:
continue
return x
except:
pass

def setlimits():
lb = getInt('Please enter a Low bound: ', (1, None))
hb = getInt('Please enter a High bound: ', (lb, 9999))
return (lb, hb)

lb, hb = setlimits()
num = getInt('Please enter a number between %d and %d' % (lb, hb),
limit=(lb, hb))

回答3:

具体要求是?