2010å¹´01æ09æ¥ 09:26 ã«ãã´ãªPython Pythonã®è¾æ¸(dictå)ãvalueå¤ã§ã½ã¼ã Posted by yawamen No Comments No Trackbacks Tweet ããããè¾æ¸(dictå)ã«ã¯é åºã¯ãªãã®ã§ãã・・・ keyå¤ãvalueå¤ã§ã½ã¼ããã¦åºåãããæãããã¾ãï¼ keyå¤ã®æã¯ç°¡å d = {'A':500, 'B':200, 'C':300, 'D':100, 'E':400} for k, v in sorted(d.items()): print k, v å®è¡çµæ A 500 B 200 C 300 D 100 E 400 valueå¤ã®æãæ¡å¤ç°¡å for k, v in sorted(d.items(), key=lambda x:x[1]): print k, v å®è¡çµæ D 100 B 200 C 300
{{#tags}}- {{label}}
{{/tags}}