• 字典dict


    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'})

  • 相关阅读:
    Maven
    Maven
    Maven
    Maven
    Maven
    Maven
    Maven
    Maven
    Maven教程
    SASS
  • 原文地址:https://www.cnblogs.com/lvjygogo/p/8441087.html
Copyright © 2020-2023  润新知