>>> flag = True
>>>
>>> while flag:
... n = raw_input("n=")
... if n in ['1','2','3','4','5','6','7','8','9','0']:
... print 'input n is : %s' % (n)
... else:
... flag = False
...
n=1
input n is : 1
n=2
input n is : 2
n=3
input n is : 3
n=j
>>>
不知道这样行不行,输入的不是数字就结束循环,否则无限循环。