for i in ‘hello’: if i == ‘l’: break print(‘当前字母是:’,i)
names = [‘xiaomeng’,‘xiaozhi’] for name in names: if name ==‘xiao’: print(“名称:”,name) break print(“循环列表名称”+name) else: print(‘没有循环!’) print(‘循环结束’) 当for循环结束会接着执行else中的函数
程序#!/user/bin/python3#_coding:UTF-8 _for i in ‘hello’:if i == ‘l’:breakprint(‘当前字母是:’,i)names = [‘xiaomeng’,‘xiaozhi’]for name in names:if name ==‘xiao’:print(“名称:”,name)breakprint(“循环列表名称...