源码之家

  • 首页
  • 文章
  • 问答
  • 下载
您的位置: 首页  >  文章  >  python创建字典的两种方法

python创建字典的两种方法

分类: 文章 • 2022-04-18 22:17:49

python创建字典的两种方法

>>> dict1 = {'name': 'earth', 'port': 80}
>>> dict2 = {}
>>> dict1,dict2
({'name': 'earth', 'port': 80}, {})
>>> 

工厂方法创建字典

>>> dict3 = dict((['x',1],['y',2]))     
>>> dict3
{'y': 2, 'x': 1}
>>> 

相关推荐

  • 自学python-自学编程的6种方法,自学Python
  • 02新建一个java工程的两种方法
  • 简诉python中image的rect方法
  • 自学python-自学python编程的方法路线
  • springboot改变bean的加载顺序【提供两种有效的方法】
  • 【 MATLAB 】使用 MATLAB 求由差分方程表示的滤波器的响应的两种方法
  • Python中的进程创建
  • python最好的学习资料_学习Python的最佳方法
  • 微信小程序开发流程的两种方法科普
  • python3.6使用spyder时,用gym运行render出错解决,以及合理的中断方法建议
  • python 高级特性:List Comprehensions(列表生成式)
  • python 高级特性:Iteration(迭代)
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 源码之家    备案号:   粤ICP备20058927号