返回顶部

收藏

Dictionaries are indexed by keys, which can be any immutable type

更多
# Dictionaries are indexed by keys, which can be any immutable type; 
# strings and numbers can always be keys. 

# Tuples can be used as keys if they contain only strings, numbers, or tuples; 
# if a tuple contains any mutable object either directly or indirectly, 
# it cannot be used as a key. 

# You can't use lists as keys, since lists can be modified.

# a dictionary is an unordered set of key: value pairs, with the requirement that the 
# keys are unique (within one dictionary). 

tel = {'jack': 4098, 'sape': 4139}
tel['guido'] = 4127
print tel

print tel['jack']

del tel['sape']
tel['irv'] = 4127
print tel

tel.keys()

print tel.has_key('guido')

print 'guido' in tel

标签:Python,Dictionary

收藏

0人收藏

支持

0

反对

0

相关聚客文章
  1. Tamim Shahriar (nore 发表 2011-10-29 03:28:10 Pythonic way to convert a list into dictionary
  2. 博主 发表 2012-08-24 04:19:00 R中媲美Python Dictionary的神器-hash
  3. 祥子 发表 2014-02-21 07:44:22 Python中的字典
  4. Tamim Shahriar (nore 发表 2012-12-10 17:28:37 Concatenate Two Dictionaries | Python How To?
  5. 潇湘 发表 2014-11-18 08:18:46 Pelican 的入门体验
  6. 博主 发表 2012-07-16 16:00:00 python自动下载chromium最新版
  7. 博主 发表 2013-08-30 00:00:00 python decorator part1
  8. naich 发表 2014-06-02 08:21:16 成交持仓量表的抓取
  9. donaldhuan 发表 2013-01-09 13:33:57 新浪微博传播路径图制作
  10. Tark Rul 发表 2014-03-02 07:01:27 小工具:SimpleRenameTool v0.7
  11. 博主 发表 2014-04-28 07:54:42 【转】python 调试工具 pdb的使用
  12. hushlight 发表 2015-04-19 03:46:54 Leetcode – Maximum Gap

发表评论