1.使用enumerate将list转换为dict

name=["lvjy","qilin","haidi"]
for item in enumerate(name):
    print(item)
View Code
name=["lvjy","qilin","haidi"]
for key,item in enumerate(name):
    print(key,item)
View Code

 2.input输入的内容为字符串,若要使用数字属性,需要进行转换

str=input("")

digit=int(str)

3.

python2.7:xrange

python3:range,for循环的时候才创建

4.dic.update({'name':'lvjy'})

posted on 2018-02-11 13:04  sonofthesea  阅读(98)  评论(0编辑  收藏  举报