python字典/字典的键值/字典属性的添加

1.python字典就相当于js里的对象

python字典里的键,要用双引号

例子:

dic = {"name":"zs","age":12}

2.python字典的值的访问,使用中括号

dic = {"name":"zs"}
print(dic["name"])  # zs

3.python字典属性的添加

使用update()方法,添加属性

例子:

dic.update("age":12)
原文地址:https://www.cnblogs.com/luguankun/p/11902190.html