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

Python create a dictionary

时间:2015-09-30 11:01:49      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:

>>> cleese={}
>>> palin=dict()
>>> type(cleese)
<class ‘dict‘>
>>> type(palin)
<class ‘dict‘>
>>> cleese[‘Name‘]=‘John Cleese‘
>>> cleese[‘Occupations‘]=[‘actor‘,‘comedian‘,‘writer‘,‘film producer‘]
>>> palin={‘name‘:‘Michael Palin‘,‘Occupations‘:[‘comedian‘,‘actor‘,‘writer‘,‘tv‘]}
>>> palin[‘name‘]
‘Michael Palin‘
>>> cleese[‘Occupations‘][-1]
‘film producer‘
>>> palin[‘Brithplace‘]="England"
>>> cleese[‘Birthplace‘]="US"
>>> palin
{‘Occupations‘: [‘comedian‘, ‘actor‘, ‘writer‘, ‘tv‘], ‘name‘: ‘Michael Palin‘, ‘Brithplace‘: ‘England‘}
>>> cleese
{‘Name‘: ‘John Cleese‘, ‘Occupations‘: [‘actor‘, ‘comedian‘, ‘writer‘, ‘film producer‘], ‘Birthplace‘: ‘US‘}
>>> 

 

Python create a dictionary

标签:

原文地址:http://www.cnblogs.com/oskb/p/4848486.html

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