zoukankan      html  css  js  c++  java
  • 51-Python字典常见的用法

    adict = dict([('name', 'bob'),('age', 30)])
    len(adict)
    hash(10)  # 判断给定的数据是不是不可变的,不可变数据才能作为key
    adict.keys()
    adict.values()
    adict.items()
    # get方法常用,重要
    adict.get('name')  # 取出字典中name对应的value,如果没有返回None
    print(adict.get('qq'))  # None
    print(adict.get('qq', 'not found'))  # 没有qq,返回指定内容
    print(adict.get('age', 'not found'))
    adict.update({'phone': '13422223333'})
  • 相关阅读:
    【leetcode】1230.Toss Strange Coins
    2018.12.25 SOW
    L203 词汇题
    L202
    L201
    L200
    2018
    2018.12.21 Cmos- RF
    L198
    L196 Hospital educations
  • 原文地址:https://www.cnblogs.com/hejianping/p/10941916.html
Copyright © 2011-2022 走看看