dict={"a":"apple","b":"banana","g":"grape","o":"orange"}
print dict
print dict["a"]
#使用数字作为索引
dict={1:"apple",2:"banana",3:"grape",4:"orange"}
print dict
print dict[2]
#字典的添加、删除
dict={1:"apple",2:"banana",3:"grape",4:"orange"}
del dict[1]
print dict
print dict[2]
#使用元组作为索引
dict={}
dict[("a","p","p","l","e")]="apple"
dict[("b","a","n","a","n","a")]="banana"
print dict
print dict[("a","p","p","l","e")]
print dict
print dict["a"]
#使用数字作为索引
dict={1:"apple",2:"banana",3:"grape",4:"orange"}
print dict
print dict[2]
#字典的添加、删除
dict={1:"apple",2:"banana",3:"grape",4:"orange"}
del dict[1]
print dict
print dict[2]
#使用元组作为索引
dict={}
dict[("a","p","p","l","e")]="apple"
dict[("b","a","n","a","n","a")]="banana"
print dict
print dict[("a","p","p","l","e")]
print"%s, %(b)s, %(a)s" %{"a":"apple","b":"banana"}
======================== RESTART: C:/Python27/dict.py ========================
{'a': 'apple', 'b': 'banana', 'o': 'orange', 'g': 'grape'}
apple
{1: 'apple', 2: 'banana', 3: 'grape', 4: 'orange'}
banana
{2: 'banana', 3: 'grape', 4: 'orange'}
banana
{('b', 'a', 'n', 'a', 'n', 'a'): 'banana', ('a', 'p', 'p', 'l', 'e'): 'apple'}
apple
{'a': 'apple', 'b': 'banana'}, banana, apple