python创建字典的两种方法

时间:2018-07-16 14:45:58   收藏:0   阅读:263
>>> dict1 = {‘name‘: ‘earth‘, ‘port‘: 80} >>> dict2 = {} >>> dict1,dict2 ({‘name‘: ‘earth‘, ‘port‘: 80}, {}) >>>

工厂方法创建字典

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

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!