#!usr/bin/env python # -*- coding:utf-8 -*- # dic={ # 'apple':10, # 'iphon':5000, # 'wwatch Tv':3000 # } # for i in dic: # print(i,dic[i]) msg=('a','b','c','d') for i in range(len(msg)): print(i) # for循环不依赖索引取值 msg_dic = { 'apple': 20, 'phone': 2000, 'banana': 10, } # 例如: for item in msg_dic: print(item, msg_dic[item]) for i in range(1, 10): # 顾头不顾尾,默认从0开始 print(i) for i in range(1, 10,2):# 步长为2 print(i) for i in range(10, 1,-1): # 倒着走 print(i)
一、九九乘法表打印:
二、统计s = 'hello alex alex say hello sb sb'中每个单词的个数