python:raw_input函数再次回到顶部

时间:2012-08-23 01:59:00

标签: python

我有一个raw_function看起来像:     number = raw_input('number(空来完成):')

if len(number) == 0:
    print
    print
    print 'finished'
    print
    print
    return def()

else:
    pass




while True:
    try:
        column2 = int(raw_input('Enter column: '))
        break
    except ValueError:
        print 'You did not supply an integer. Please try again. '

当我完成第二次raw_input的回答时,我想回到第一个raw_input。 我怎么能这样做?

提前致谢。

1 个答案:

答案 0 :(得分:1)

   while True:
     number = raw_input('number (empty to finish): ')
     if not number:
        print "\n\nfinished\n\n\n"
        return def()
     while True:
        try:
            column2 = int(raw_input('Enter column: '))
            break
        except ValueError:
            print 'You did not supply an integer. Please try again. '