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

python »ù´¡

   Python¿ìËÙÈëÃÅ
                        Ŀ¼
1. µÚÒ»Õ Python¿ìËÙÈëÃÅ
                           
±¾ÕÂÊÇPythonµÄ¿ìËÙÈëÃÅ,ÔÚÕâÒ»Õ²¢²»Éæ¼° pythonµÄÌØÊâ¹æÔòºÍϸ½Ú,Ä¿±êÊÇͨ¹ýʾÀýʹ Äã¿ìËÙÁ˽âPythonÓïÑÔµÄÌص㡣±¾Õ¼òÒª½éÉÜÁ˱äÁ¿,±í´ïʽ,¿ØÖÆÁ÷,º¯ÊýÒÔ¼°ÊäÈë/Êä³öµÄ»ù±¾¸ÅÄî,ÔÚÕâÒ»Õ²»Éæ¼°PythonÓïÑԵĸ߼¶ÌØÐÔ¡£
 1. ÔËÐÐPython
 2. ±äÁ¿ºÍ±í´ïʽ
 3. Ìõ¼þÓï¾ä
 4. ÎļþÊäÈë/Êä³ö
 5. ×Ö·û´®
 6. ÁбíºÍÔª×é(Lists & Tuples)                       
 7. Ñ­»·
 8. ×Öµä
 9. º¯Êý
 10. Àà
 11. Òì³£
 12. Ä£¿é
1.1ÔËÐÐpython
Python ³ÌÐòͨ¹ý½âÊÍÆ÷Ö´ÐС£Èç¹ûÄãµÄ»úÆ÷ÒѾ­×°ºÃÁËpython,¼òµ¥µÄÔÚÃüÁîÐмü
Èëpython¼´¿ÉÔËÐÐpython½âÊÍÆ÷¡£ÔÚ½âÊÍÆ÷ÔËÐеÄʱ,»áÓÐÒ»¸öÃüÁîÌáʾ·û >>>,
ÔÚÌáʾ·ûºó¼üÈëÄãµÄ³ÌÐòÓï¾ä,¼üÈëµÄÓï¾ä½«»áÁ¢¼´Ö´ÐС£ÔÚϱߵÄÀý×ÓÖÐ,ÎÒÃÇ
ÔÚ>>>Ìáʾ·ûºó±ß¼üÈë×î³£¼ûµÄÏÔʾ"Hello World"µÄÃüÁî:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello world"
hello world
>>> print 'hello world'
hello world
³ÌÐòÒ²¿ÉÒÔÏñÏÂÃæÒ»Ñù·ÅÖÃÔÚÒ»¸öÎļþÖÐ,ÎÒʹÓÃvim±à¼­Æ÷±à¼­hello.py³ÌÐò¡£
ÔÚUNIXÏÂ,Äã¿ÉÒÔÔÚ³ÌÐòµÄÊ×ÐÐдÈë #! ħ·¨×Ö·û´® À´×Ô¶¯µ÷ÓÃpython½âÊÍÆ÷Ö´ÐÐÄã
µÄ½Å±¾¡£
#!/usr/bin/python
print "hello world"
È»ºóÔÚpythonÖÐÔËÐÐ
windyang@windyang-desktop:~$ python helloworld.py
hello world
PythonÔ´´úÂëÎļþʹÓÃ.pyºó׺.'#'±íʾעÊÍ(µ½ÐÐÄ©½áÊø)£¬µ±È»¶ÔÓÚÕâ¸öÎļþÄãÒ²¿ÉÒÔʹÓú¯Êýexecfile()À´ÔËÐÐÒ»¸ö±¨´æÔÚ´ÅÅÌÉϵijÌÐò
>>> execfile(&quo


Ïà¹ØÎĵµ£º

pythonÄ£¿éÖ®ConfigParser ini

תÔØ×Ô£ºhttp://hi.baidu.com/myitlyj/blog/item/25586bd7088ba3dba044df6b.html
ÔÚ³ÌÐòÖÐʹÓÃÅäÖÃÎļþÀ´Áé»îµÄÅäÖÃһЩ²ÎÊýÊÇÒ»¼þºÜ³£¼ûµÄÊÂÇ飬ÅäÖÃÎļþµÄ½âÎö²¢²»¸´ÔÓ£¬ÔÚpythonÀï¸üÊÇÈç´Ë£¬ÔÚ¹Ù·½·¢²¼µÄ¿âÖоͰüº¬ÓÐ×öÕâ¼þÊÂÇéµÄ¿â£¬ÄǾÍÊÇConfigParser£¬ÕâÀï¼òµ¥µÄ×öһЩ½éÉÜ¡£
ConfigParser½âÎöµÄÅäÖÃÎļþµÄ¸ñÊ ......

pythonÖÐÕýÔò±í´ïʽÓëre Ä£¿é

1. 9.7 ÕýÔò±í´ïʽÓë re Ä£¿é
Ò»¸öÕýÔò±í´ïʽ¾ÍÊÇÒ»¸öÓÃÀ´±íʾijÖÖģʽµÄ×Ö·û´®¡£ËüÄÜ°ïÖúÄã·½±ãµÄ¼ì²éÒ»¸ö×Ö·û´®ÊÇ·ñÓëijÖÖģʽƥÅä¡£
re Ä£¿éʹ Python ÓïÑÔÓµÓÐÈ«²¿µÄÕýÔò±í´ïʽ¹¦ÄÜ¡£ compile º¯Êý¸ù¾ÝÒ»¸öģʽ×Ö·û´®ºÍ¿ÉÑ¡µÄ±êÖ¾²ÎÊýÉú³ÉÒ»¸öÕýÔò±í´ïʽ¶ÔÏ󡣸öÔÏóÓµÓÐһϵÁз½·¨ÓÃÓÚÕýÔò±í´ïʽƥÅäºÍÌæ»»¡£ re Ä£ ......

beginning python summary chapter 2 ÁбíºÍÔª×é

1¡¢ÔÚPythonÖÐ×î»ù±¾µÄÊý¾Ý½á¹¹ÊÇÐòÁУ¨sequence£©£¬ÐòÁÐÖеÄÿ¸öÔªËر»·ÖÅäÒ»¸öÊý×Ö——ÔªËصÄλÖã¬Ò²½ÐË÷Òý¡£µÚÒ»¸öË÷ÒýÊÇ    0£¬µÚ¶þ¸öË÷ÒýÊÇ1£¬Èç´ËµÝÍÆ¡£ÐòÁÐÖеÄ×îºóÒ»¸öÌõÄ¿±»±ê¼ÇΪ-1£¬µ¹ÊýµÚ¶þÊÇ-2£¬Èç´ËµÝÍÆ¡£
2¡¢ÐòÁУºeg:edward = ['Edward Gumby', 42]£¬ÐòÁÐÒ²ÄÜ°üº¬ÆäËûµÄÐòÁС£Ð ......

Python³õѧ±Ê¼Ç£¨×ªÔØ£©


while µÄÓ÷¨£º
while ºóÃæ¸úÌõ¼þ±í´ïʽ£¬(:)ºóÃæ¸úÓï¾ä¿é£¬Äã¿ÉÒÔÔÚÕâ¶ÎÓï¾ä¿éÀïÐÞ¸ÄÌõ¼þ±í´ïʽµÄijЩ±äÁ¿£¬µ±Ìõ¼þ±í´ïʽ Ϊ¼ÙµÄʱºòÍ˳öÑ­»·¡£ÀýÈ磺
flag = 5
while flag > 0:
#ÕâÀïÊÇÄãµÄ´úÂë
flag -= 1
#if flag == 3: break
#if flag == 3: continue
print flag
µ±È»ÄãÒ²¿ÉÒÔÔÚÊʵ ......

PythonÕýÔò±í´ïʽ²Ù×÷Ö¸ÄÏ[ת]

Ô­Îijö´¦£ºhttp://www.amk.ca/python/howto/regex/
Ô­ÎÄ×÷ÕߣºA.M. Kuchling £¨amk@amk.ca£©
ÊÚȨÐí¿É£º´´×÷¹²ÏíЭÒé
·­ÒëÈËÔ±£ºFireHare
У¶ÔÈËÔ±£ºLeal
ÊÊÓð汾£ºPython 1.5 ¼°ºóÐø°æ±¾
¼ò½é
Python ×Ô1.5°æ±¾ÆðÔö¼ÓÁËre Ä£¿é£¬ËüÌṩ Perl ·ç¸ñµÄÕýÔò±í´ïʽģʽ¡£Python 1.5֮ǰ°æ±¾ÔòÊÇͨ¹ý regex
Ä£¿éÌṩ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ