1.使用enumerate将list转换为dict
name=["lvjy","qilin","haidi"] for item in enumerate(name): print(item)
name=["lvjy","qilin","haidi"] for key,item in enumerate(name): print(key,item)
2.input输入的内容为字符串,若要使用数字属性,需要进行转换
str=input("")
digit=int(str)
3.
python2.7:xrange
python3:range,for循环的时候才创建
4.dic.update({'name':'lvjy'})