2013-12-29 17:34:42 -05:00
|
|
|
# using strings as keys in dict
|
|
|
|
|
|
|
|
d = {'1': 1, '2': 2}
|
|
|
|
print(d['1'], d['2'])
|
|
|
|
|
|
|
|
d['3'] = 3
|
|
|
|
print(d['1'], d['2'], d['3'])
|
|
|
|
|
|
|
|
d['2'] = 222
|
|
|
|
print(d['1'], d['2'], d['3'])
|
2014-04-06 14:21:35 -04:00
|
|
|
|
|
|
|
d2 = dict(d)
|
|
|
|
print('2' in d2)
|
|
|
|
print(id(d) != id(d2), d == d2)
|
2014-04-10 22:24:44 -04:00
|
|
|
|
|
|
|
print(d.__getitem__('2'))
|