#!/usr/bin/env python #-*- coding:utf-8 -*- #打印0001-9999的数字 for i in range(9999): s = "%04d" % i print(s) #循环打印字典 dict1 = {"tom":90,"dgg":100,"sb":-1} for a in dict1: print(a,dict1[a]) #打印dict1的值 for value in dict1.values(): print(value) #dict1.items 返回的是一个完整的列表 print(dict1.items()) #k与v分别对应的是key和value for k,v in dict1.items(): print(k,v) #enumerate 显示字典key的下标 for i,v2 in enumerate(dict1): print(i,v2)