huashan8 发表于 2017-4-30 12:44:01

python 字典,,看这个...

  >>> legends = { ('Poe', 'author'): (1809, 1849, 1976),
... ('Gaudi', 'architect'): (1852, 1906, 1987),
... ('Freud', 'psychoanalyst'): (1856, 1939, 1990)
... }
...
>>> for eachLegend in legends:
...      print 'Name: %s\tOccupation: %s' % eachLegend
 ...        print ' Birth: %s\tDeath: %s\tAlbum: %s\n' \
 ...        % legends
 ...
 Name: Freud Occupation: psychoanalyst
Birth: 1856 Death: 1939 Album: 1990
Name: Poe Occupation: author
Birth: 1809 Death: 1849 Album: 1976
Name: Gaudi Occupation: architect
Birth: 1852 Death: 1906 Album: 1987
页: [1]
查看完整版本: python 字典,,看这个...