Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Amusing Python 2: range/xrange

ÕâÁ½¸ö»ù±¾É϶¼ÊÇÔÚÑ­»·µÄʱºòÓá£
Python
´úÂë < type="application/x-shockwave-flash" width="14" height="15" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=for%20i%20in%20range(0%2C%20100)%3A%0A%20%20%20%20print%20i" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="15" width="14">
for
 i 
in
 range
(
0

100
):  
    print
 i  
for i in range
(0, 100):
print i
Python
´úÂë < type="application/x-shockwave-flash" width="14" height="15" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=for%20i%20in%20xrange(0%2C%20100)%3A%0A%20%20%20%20print%20i" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="15" width="14">
for
 i 
in
 xrange(
0

100
):  
    print
 i  
for i in xrange(0, 100):
print i
  
ÕâÁ½¸öÊä³öµÄ½á¹û¶¼ÊÇ
Ò»ÑùµÄ£¬Êµ¼ÊÉÏÓкܶ಻ͬ£¬range
»áÖ±½ÓÉú³ÉÒ»¸ölist¶ÔÏó£º
Python
´úÂë < type="application/x-shockwave-flash" width="14" height="15" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%3E%3E%3E%20a%20%3D%20range(0%2C%2010)%0A%3E%3E%3E%20type(a)%0A%3Ctype%20'list'%3E%0A%3E%3E%3E%20a%0A%5B0%2C%201%2C%202%2C%203%2C%204%2C%205%2C%206%2C%207%2C%208%2C%209%5D%0A%3E%3E%3E%20a%5B0%5D%0A0" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/g


Ïà¹ØÎĵµ£º

Python±ê×¼¿â tracebackÄ£¿é

Example 2-18 չʾÁË traceback Ä£¿éÔÊÐíÄãÔÚ³ÌÐòÀï´òÓ¡Òì³£µÄ¸ú×Ù·µ»Ø
(Traceback)ÐÅÏ¢, ÀàËÆ䲶»ñÒ쳣ʱ½âÊÍÆ÷Ëù×öµÄ. Èç Example 2-18 Ëùʾ. 2.11.0.1. Example
2-18. ʹÓà traceback Ä£¿é´òÓ¡¸ú×Ù·µ»ØÐÅÏ¢ File: traceback-example-1.py # note!
import
Example 2-18 չʾÁË traceback Ä£¿éÔÊÐíÄãÔÚ³ÌÐòÀï´òÓ¡Òì³£ ......

vim python µÄpath»·¾³±äÁ¿

ÒÔǰҲд¹ýһЩ¹ØÓÚ vim »·¾³±äÁ¿µÄÄÚÈÝ£¬Ê¹Óà vim ºÍ python £¬Ã¿Ò»¶Îʱ¼äºó¶¼»áÓÐеÄÌå»á£¬ËùÒÔÒª²»¶Ï×ܽáÁË.
vim Õë¶Ô python µÄÍòÄܲ¹È«£º vim µ±Ç°½ø³ÌÐèÒªÕÒµ½ÏàÓ¦²¹È«Ä£¿é¿âËùÔÚλÖ㬴ËÊÇ¾ÍºÍ python µÄpath»·¾³±äÁ¿Ïà¹Ø¡£
python ´úÂëÔËÐÐʱ: ¶ÔÓÚimport µÄÄ£¿éÒ²ÐèҪȷ¶¨ËüµÄ¾ßÌåλÖÃ,python ½âÊÍÆ÷»áµ½µ±Ç°Â· ......

pythonÄ£¿é

¼ò½é
ÄãÒѾ­Ñ§Ï°ÁËÈçºÎÔÚÄãµÄ³ÌÐòÖж¨ÒåÒ»´Îº¯Êý¶øÖØÓôúÂë¡£Èç¹ûÄãÏëÒªÔÚÆäËû³ÌÐòÖÐÖØÓúܶຯÊý£¬ÄÇôÄã¸ÃÈçºÎ±àд³ÌÐòÄØ£¿Äã¿ÉÄÜÒѾ­²Âµ½ÁË£¬´ð°¸ÊÇʹÓÃÄ£¿é¡£Ä£¿é»ù±¾ÉϾÍÊÇÒ»¸ö°üº¬ÁËËùÓÐÄ㶨ÒåµÄº¯ÊýºÍ±äÁ¿µÄÎļþ¡£ÎªÁËÔÚÆäËû³ÌÐòÖÐÖØÓÃÄ£¿é£¬Ä£¿éµÄÎļþÃû±ØÐëÒÔ.pyΪÀ©Õ¹Ãû¡£
Ä£¿é¿ÉÒÔ´ÓÆäËû³ÌÐò ÊäÈë ÒÔ±ãÀûÓÃËüµ ......

ѧϰpython½Å±¾ÓïÑԱʼǣ¨1£©

ptyhonºËÐıà³ÌµÚÈý°æµÄ×Ôѧ£¬Ö÷Ҫѧϰ±Ê¼Ç·¢Ï£º
µÚÒ»Õ£ºÊ¹ÓÃÈëÃÅ
ÈËÃÇΪʲôʹÓÃPYTHONÓïÑÔ£º
1¡¢Èí¼þÖÊÁ¿£»
2¡¢¿ª·¢ÕßЧÂÊ£»
3¡¢³ÌÐòµÄ¿ÉÒÆÖ²ÐÔ£»
4¡¢×é¼þ¼¯³É£»
5¡¢ÏíÊÜÀÖȤ£»
PYTHONÓïÑÔµÄȱµã£¬¾ÍÊÇËÙ¶ÈÂý¡£
ʹÓÃPYTHON¿ÉÒÔ×öЩʲô£º
1¡¢ÏµÍ³±à³Ì£»
2¡¢Óû§Í¼Ðνӿڣ»
3¡¢INTERNET½Å±¾£»
4¡¢×é¼þ¼¯³É£ ......

Python Ôª×é


Python Ôª×é
Ôª×éºÍÁбíÊ®·ÖÀàËÆ£¬Ö»²»¹ýÔª×éºÍ×Ö·û´®Ò»ÑùÊÇ ²»¿É±äµÄ ¼´Äã²»ÄÜÐÞ¸ÄÔª×é¡£Ôª×éͨ¹ýÔ²À¨ºÅÖÐÓöººÅ·Ö¸îµÄÏîÄ¿¶¨Òå¡£Ôª×éͨ³£ÓÃÔÚʹÓï¾ä»òÓû§¶¨ÒåµÄº¯ÊýÄܹ»°²È«µØ²ÉÓÃÒ»×éÖµµÄʱºò£¬¼´±»Ê¹ÓõÄÔª×éµÄÖµ²»»á¸Ä±ä¡£
ʹÓÃÔª×é
Àý9.2 ʹÓÃÔª×é
#!/usr/bin/python
# Filename: using_tuple.py
zoo = ('wo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ