python dict函数

来源:互联网 发布:java兼职平台 编辑:程序博客网 时间:2024/06/16 23:14
print '--------------begin-dict------------------'#初始化一个字典d = dict({'one': 1, 'two': 2})print dd = dict(one=1, two=2)print dd = dict([(['one', 'two'][i - 1], i) for i in (1, 2)])print dd = dict({'one': 1, 'two': 2}.items())print dd = dict(zip(('one', 'two'), (1, 2)))print dprint '--------------end-dict------------------'


输出:

--------------begin-dict------------------
{'two': 2, 'one': 1}
{'two': 2, 'one': 1}
{'two': 2, 'one': 1}
--------------end-dict------------------

0 0
原创粉丝点击