4月 7th, 2008at 15:30

Tags:

Python2.5のディクショナリ

このエントリーをはてなブックマークに追加
print {}print {1:1, 2:2}print {"1":"value1", "2":"value2"}print {1:1, 2:{1:1, 2:2}}

dic = {1:1, 2:2, 3:3}

print dic[1]print dic.has_key(3)print dic.keys()print dic.values()print len(dic)

dic2 = {3:4, 4:4}dic.update(dic2)

print dic

実行結果

{}{1: 1, 2: 2}{'1': 'value1', '2': 'value2'}{1: 1, 2: {1: 1, 2: 2}}1True[1, 2, 3][1, 2, 3]3{1: 1, 2: 2, 3: 4, 4: 4}
このエントリーをはてなブックマークに追加