码迷,mamicode.com
首页 > 编程语言 > 详细

python创建字典的两种方法

时间:2018-07-16 15:04:27      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:两种方法   字典   pre   earth   dict   工厂方法   创建   方法   pytho   

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

工厂方法创建字典

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

python创建字典的两种方法

标签:两种方法   字典   pre   earth   dict   工厂方法   创建   方法   pytho   

原文地址:http://blog.51cto.com/yht1990/2144323

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!