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)

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案