2006年10月30日 星期一 10:58
hey all. --------- #!/usr/bin/python ab = { 'Swaroop' : 'swaroopch在byteofpython.info', 'Larry' : 'larry在wall.org', 'Matsumoto' : 'matz在ruby-lang.org', 'Guido' = 'guido在python.org' } for name, address in ab.items(): print 'Contact %s at %s' % (name, address) ------- output ------- $ python using_dict.py Contact Swaroop at swaroopch在byteofpython.info Contact Matsumoto at matz在ruby-lang.org Contact Larry at larry在wall.org Contact Guido at guido在python.org 这个输出为什么不是 Contact Swaroop at swaroopch在byteofpython.info Contact Larry at larry在wall.org Contact Matsumoto at matz在ruby-lang.org Contact Guido at guido在python.org 这里的赋值是按什么排序的?
2006年10月30日 星期一 11:04
> 这里的赋值是按什么排序的? 字典的key是无序的。如果要排序需要自已做,或者通过keys()来排,或者通过items()来排。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2006年10月30日 星期一 11:05
Dictionary have no order. ----- Original Message ----- From: <lveax.m at gmail.com> To: <python-chinese at lists.python.cn> Date: 2006年10月30日 上午 10:58 Subject: [python-chinese] 字典在for...in..中的赋值顺序问题 > hey all. > > --------- > #!/usr/bin/python > > ab = { 'Swaroop' : 'swaroopch at byteofpython.info', > 'Larry' : 'larry at wall.org', > 'Matsumoto' : 'matz at ruby-lang.org', > 'Guido' = 'guido at python.org' > } > > for name, address in ab.items(): > print 'Contact %s at %s' % (name, address) > > ------- > output > ------- > $ python using_dict.py > > Contact Swaroop at swaroopch at byteofpython.info > Contact Matsumoto at matz at ruby-lang.org > Contact Larry at larry at wall.org > Contact Guido at guido at python.org > > 杩欎釜杈撳嚭涓轰粈涔堜笉鏄?BR> > Contact Swaroop at swaroopch at byteofpython.info > Contact Larry at larry at wall.org > Contact Matsumoto at matz at ruby-lang.org > Contact Guido at guido at python.org > > 杩欓噷鐨勮祴鍊兼槸鎸変粈涔堟帓搴忕殑? > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese Jianhua Zhu Tel: +86-769-87318190 EXT: 164
2006年10月30日 星期一 11:07
python-chinese£¬ÄãºÃ ×ÖµäÊÇHashµÄ£¬Ôõô»áÓÐ˳Ðò¡£Èç¹ûÒª±£³Ö˳Ðò¿ÉÒÔÓÃÊý×éºÍ×ÖµäÅäºÏʹÓà Jamsa£¬zhujiemao在126.com 2006-10-30 ----- Original Message ----- From: lveax.m To: python-chinese Sent: 2006-10-30, 10:58:53 Subject: [python-chinese] ×ÖµäÔÚfor...in..Öеĸ³ÖµË³ÐòÎÊÌâ hey all. --------- #!/usr/bin/python ab = { 'Swaroop' : 'swaroopch在byteofpython.info', 'Larry' : 'larry在wall.org', 'Matsumoto' : 'matz在ruby-lang.org', 'Guido' = 'guido在python.org' } for name, address in ab.items(): print 'Contact %s at %s' % (name, address) ------- output ------- $ python using_dict.py Contact Swaroop at swaroopch在byteofpython.info Contact Matsumoto at matz在ruby-lang.org Contact Larry at larry在wall.org Contact Guido at guido在python.org Õâ¸öÊä³öΪʲô²»ÊÇ Contact Swaroop at swaroopch在byteofpython.info Contact Larry at larry在wall.org Contact Matsumoto at matz在ruby-lang.org Contact Guido at guido在python.org ÕâÀïµÄ¸³ÖµÊÇ°´Ê²Ã´ÅÅÐòµÄ? _______________________________________________ python-chinese Post: send python-chinese在lists.python.cn Subscribe: send subscribe to python-chinese-request在lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061030/66ec6d8b/attachment.htm
Zeuux © 2025
京ICP备05028076号