continue

来源:互联网 发布:java spring 单例模式 编辑:程序博客网 时间:2024/05/18 01:25
while True:
    s = input('Enter something:')
    if s == 'quit':
        break
    if len(s) < 3:
        continue

    print('Input is of sufficient length')




此例中,如果输入的string长度小于3,则continue后的语句不会被执行,直接重复循环。

原创粉丝点击