for x in 'abc': print(x) #a #b #c print('##################################') # 生成5、6 for x in range(5,7): print(x) #5 #6 print('##################################') #range的第三个参数是步长 for x in range(1,10,2): print(x) #1 #3 #5 #7 #9 print('##################################') # 遍历字典 dic = {'a':'123', 'b':'456', 'c':'789'} for k,v in dic.items(): print(k) print(v) #c #789 #b #456 #a #123 print('##################################') for x in range(1,10): print(x) if x == 5: break #1 #2 #3 #4 #5