Python ×Öµä
Python ×Öµä
×ÖµäÀàËÆÓÚÄãͨ¹ýÁªÏµÈËÃû×Ö²éÕÒµØÖ·ºÍÁªÏµÈËÏêϸÇé¿öµÄµØÖ·²¾£¬¼´£¬ÎÒÃǰѼü£¨Ãû×Ö£©ºÍÖµ£¨ÏêϸÇé¿ö£©ÁªÏµÔÚÒ»Æð¡£×¢Ò⣬¼ü±ØÐëÊÇΨһµÄ£¬¾ÍÏñÈç¹ûÓÐÁ½¸öÈËÇ¡ÇÉͬÃûµÄ»°£¬ÄãÎÞ·¨ÕÒµ½ÕýÈ·µÄÐÅÏ¢¡£
×¢Ò⣬ÄãÖ»ÄÜʹÓò»¿É±äµÄ¶ÔÏ󣨱ÈÈç×Ö·û´®£©À´×÷Ϊ×ÖµäµÄ¼ü£¬µ«ÊÇÄã¿ÉÒÔ²»¿É±ä»ò¿É±äµÄ¶ÔÏó×÷Ϊ×ÖµäµÄÖµ¡£»ù±¾ËµÀ´¾ÍÊÇ£¬ÄãÓ¦¸ÃֻʹÓüòµ¥µÄ¶ÔÏó×÷Ϊ¼ü¡£
¼üÖµ¶ÔÔÚ×ÖµäÖÐÒÔÕâÑùµÄ·½Ê½±ê¼Ç£ºd = {key1 : value1, key2 : value2 }¡£×¢ÒâËüÃǵļü/Öµ¶ÔÓÃðºÅ·Ö¸î£¬¶ø¸÷¸ö¶ÔÓöººÅ·Ö¸î£¬ËùÓÐÕâЩ¶¼°üÀ¨ÔÚ»¨À¨ºÅÖС£
¼Çס×ÖµäÖеļü/Öµ¶ÔÊÇûÓÐ˳ÐòµÄ¡£Èç¹ûÄãÏëÒªÒ»¸öÌØ¶¨µÄ˳Ðò£¬ÄÇôÄãÓ¦¸ÃÔÚʹÓÃǰ×Ô¼º¶ÔËüÃÇÅÅÐò¡£
×ÖµäÊÇdictÀàµÄʵÀý/¶ÔÏó¡£
ʹÓÃ×Öµä
Àý9.4 ʹÓÃ×Öµä
#!/usr/bin/python
# Filename: using_dict.py
# 'ab' is short for 'a'ddress'b'ook
ab = { 'Swaroop' : 'swaroopch@byteofpython.info',
'Larry' : 'larry@wall.org',
'Matsumoto' : 'matz@ruby-lang.org',
'Spammer' : 'spammer@hotmail.com'
}
print "Swaroop's address is %s" % ab['Swaroop']
# Adding a key/value pair
ab['Guido'] = 'guido@python.org'
# Deleting a key/value pair
del ab['Spammer']
print '/nThere are %d contacts in the address-book/n' % len(ab)
for name, address in ab.items():
print 'Contact %s at %s' % (name, address)
if 'Guido' in ab: # OR ab.has_key('Guido')
print "/nGuido's address is %s" % ab['Guido']
£¨Ô´Îļþ£ºcode/using_dict.py£©
Êä³ö
$ python using_dict.py
Swaroop's address is swaroopch@byteofpython.info
There are 4 contacts in the address-book
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
Guido's address is guido@python.org
ËüÈçºÎ¹¤×÷
Ïà¹ØÎĵµ£º
Ian Maurer (ian@itmaurer.com), ×ÊÉî¹ËÎÊ, Brulant, Inc.
2006 Äê 7 ÔÂ 03 ÈÕ
±¾ÏµÁÐÎÄÕÂÒ»¹²ÓÐÁ½Æª£¬±¾ÎÄÊÇÆäÖеĵÚһƪ¡£ÔÚÕâһƪÎÄÕÂÖУ¬ÎÒÃǽ«Õ¹Ê¾ Django µÄÓ÷¨£¬Django ÊÇ Python ±à³ÌÓïÑÔÇý¶¯µÄÒ»¸ö¿ªÔ´Ä£ÐÍ-ÊÓͼ-¿ØÖÆÆ÷£¨MVC£©·ç¸ñµÄ Web Ó¦ÓóÌÐò¿ò¼Ü¡£Ê¹Óà Django£¬ÎÒÃÇÔÚ¼¸·ÖÖÓÖ®ÄÚ¾ ......
ΪÁËÈÃUEÖ§³ÖpythonÓïÑÔ£¬googleÁ˺ܶ࣬½á¹û¶¼²»ÐУ¬×îºó¿´ÁËÏÂÃæµÄ²©¿Í²ÅÖªµÀ´íÄÄÁË£¬×ܽáÏÂÒÔÃâÍü¼Ç¡£
http://wangtao.name/2009/12/20/ultraedit_python.html
ÔÚ¹ÙÍøÉÏÕÒµ½pythonµÄÀ©Õ¹ÏÂÔØµã£ºhttp://www.ultraedit.com/downloads/extras.html
Óи÷ÖÖÓïÑÔµÄÀ©Õ¹£¬±ã¿ÉÒÔÖ§³ÖÓï·¨¸ßÁÁ¡£
python 2.5£ºhttp://www.u ......
Including binaries in your sources
+y F J2A T&N1H f(L ]0
Sometime it's handy to include small files in your sources (icons, test files, etc.)CNOUG²©¿ÍÊ×Ò³ P x z c W R K+x3{ N
CNOUG²©¿ÍÊ×Ò³ h I A O$k-n P
Let's take a file (myimage.gif) and convert it in base64 (optionnaly compressing it wit ......
1. What’s the difference between all of the os.popen() methods?
popen2 doesn't capture standard error, popen3 does capture standard
error and gives a unique file handle for it. Finally, popen4 captures
standard error but includes it in the same file object as standard
output.
os.popen()&n ......
Python Áбí
listÊÇ´¦ÀíÒ»×éÓÐÐòÏîÄ¿µÄÊý¾Ý½á¹¹£¬¼´Äã¿ÉÒÔÔÚÒ»¸öÁбíÖд洢һ¸ö ÐòÁÐ µÄÏîÄ¿¡£¼ÙÏëÄãÓÐÒ»¸ö¹ºÎïÁÐ±í£¬ÉÏÃæ¼ÇÔØ×ÅÄãÒªÂòµÄ¶«Î÷£¬Äã¾ÍÈÝÒ×Àí½âÁбíÁË¡£Ö»²»¹ýÔÚÄãµÄ¹ºÎï±íÉÏ£¬¿ÉÄÜÿÑù¶«Î÷¶¼¶À×ÔÕ¼ÓÐÒ»ÐУ¬¶øÔÚPythonÖУ¬ÄãÔÚÿ¸öÏîĿ֮¼äÓöººÅ·Ö¸î¡£
ÁбíÖеÄÏîĿӦ¸Ã°üÀ¨ÔÚ·½À¨ºÅÖУ¬ÕâÑùPython¾ÍÖªµÀÄãÊ ......