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

Python ιʶøÖªÐÂ

1. ´òÓ¡±äÁ¿ºÍ±äÁ¿×ÔÏÔ
>>> myString = 'Hello World!'
>>> print myString
Hello World!
>>> myString
'Hello World!'
ÒòΪ£º print Óï¾äµ÷ÓÃstr()º¯ÊýÏÔʾ¶ÔÏ󣬶ø½»»¥Ê½½âÊÍÆ÷Ôòµ÷ÓÃrepr()º¯ÊýÀ´ÏÔʾ¶ÔÏó
sys.stdout.write('hello')²»»áÔÚĩβ¼ÓÉÏ'\n'£¬¶øprint»á
2. ´òÓ¡Îļþ
handle = open('poem.txt', 'r')
for eachline in handle:
    print eachline,
handle.close()
ÊÊÓÃÓÚÎļþ´óСÊÊÖеÄÎļþ¡£¶ÔÓںܴóµÄÎļþÀ´Ëµ£¬ ÉÏÃæµÄ´úÂë»áÕ¼ÓÃÌ«¶àµÄÄڴ棬 ÕâʱÄã×îºÃÒ»´Î¶ÁÒ»ÐÐ
3. Ä£¿éÔÙÒé
Ä£¿éÊÇÒ»ÖÖ×éÖ¯ÐÎʽ£¬ Ëü½«±Ë´ËÓйØϵµÄPython ´úÂë×éÖ¯µ½Ò»¸ö¸ö¶ÀÁ¢Îļþµ±ÖС£
Ä£¿é¿ÉÒÔ°üº¬¿ÉÖ´ÐдúÂ룬 º¯ÊýºÍÀà»òÕßÕâЩ¶«Î÷µÄ×éºÏ¡£
4. ʵÓú¯Êý
dir([obj])              ÏÔʾ¶ÔÏóµÄÊôÐÔ£¬Èç¹ûûÓÐÌṩ²ÎÊý£¬ ÔòÏÔʾȫ¾Ö±äÁ¿µÄÃû×Ö
help([obj])           ÒÔÒ»ÖÖÕûÆëÃÀ¹ÛµÄÐÎʽ ÏÔʾ¶ÔÏóµÄÎĵµ×Ö·û´®£¬ Èç¹ûûÓÐÌṩÈκβÎÊý£¬ Ôò»á½øÈë½»»¥Ê½°ïÖú¡£
int(obj)                ½«Ò»¸ö¶ÔÏóת»»ÎªÕûÊý
len(obj)               ·µ»Ø¶ÔÏóµÄ³¤¶È
open(fn, mode)   ÒÔ mode('r' = ¶Á£¬ 'w'= д)·½Ê½´ò¿ªÒ»¸öÎļþÃûΪ fn µÄÎļþ
range([[start,]stop[,step]) ·µ»ØÒ»¸öÕûÊýÁÐ±í¡£ÆðʼֵΪ start, ½áÊøֵΪ stop - 1; startĬÈÏֵΪ 0£¬ stepĬÈÏֵΪ1¡£
raw_input(str)  µÈ´ýÓû§ÊäÈëÒ»¸ö×Ö·û´®£¬ ¿ÉÒÔÌṩһ¸ö¿ÉÑ¡µÄ²ÎÊý str ÓÃ×÷ÌáʾÐÅÏ¢¡£
str(obj)               ½«Ò»¸ö¶ÔÏóת»»Îª×Ö·û´®
type(obj)             ·µ»Ø¶ÔÏóµÄÀàÐÍ£¨·µ»ØÖµ±¾ÉíÊÇÒ»¸ötype ¶ÔÏ󣡣©
5. ¹Ø¼ü×Ö
and del from not while
as elif global or with
assert else if pass yield
break except import print
class exec in raise


Ïà¹ØÎĵµ£º

£¨×ª£©UnicodeºÍPythonµÄÖÐÎÄ´¦Àí

      ——ÓÉÓÚ×î½üÔÚ×öÓйØÍøÒ³ËÑË÷µÄÏîÄ¿£¬Éæ¼°µ½Ò»Ð©±àÂë·½ÃæµÄ֪ʶ£¬Ð¡µÜÔÚÍøÉÏżȻµØ·¢ÏÖÁËÕâôһƪÎÄÕ£¬ºÜÒ׶®£¬²»»Þɬ£¬ÎªÁË·½±ã×Ô¼ºÒ²Í¬Ê±ÄÜ·½±ã´ó¼Ò£¬¾ÍתÁ˹ýÀ´£¬ÒÔ×÷²Î¿¼……
      ÎÄÕ³ö´¦£ºhttp://blog.csdn.net/tingsking18/arc ......

PythonºÍPHPÖ®±È½Ï

  ż¶û×ö¸ö¼òµ¥µÄWEB·þÎñ²âÊÔ³ÌÐò£¬ÎÒ»¹ÊÇϲ»¶²ÉÓÃPHP¡£¼ò½à£¬·ç¸ñºÍC/C++½Ó½ü£¬ÉÏÊֿ죬¶øÇÒ¿âÒ²ºÜÆëÈ«¡£ÒÔǰΪ¹ã¶«Òƶ¯×öÒƶ¯ÐÐÒµÖն˵ÄÑÝʾ³ÌÐòʱ£¬²ÉÓùúÄÚÒ»¸öÐÖµÜдµÄFleaPHP¿ªÔ´¿ò¼Ü£¬Á½Öܲ»µ½µÄʱ¼ä£¬ÎÒ´ÓÒ»¸ö¶ÔPHPÒ»ÎÞËùÖªµÄˮƽ£¬¿ìËٵĸ㶨ÁË30¶à¸öÒ³ÃæµÄºǫ́£¬ºóÀ´ÑÝʾЧ¹ûÒ²²»´í£¬Ò²ºÜÎȶ¨£¬´Ó´Ë¶ÔPHPÓÐÁ ......

Python Socket Server

½ñÌì×öftpµÄ½çÃæ,×öµÄÏ൱ÓôÃÆ£¬ÅªµÃÐÄÇé¼°Æ䲻ˬ£¬ÔÚÍøÉÏËѵ½ËÀ¶¼²»ÖªµÀ¸ÃÔõô°ì£¬´òËãÃ÷ÌìÏÈ¿´¿´C£«£«
µÄÊÇÔõôŪµÄÔÙ˵¡£²»¹ý£¬ÏÖÔÚÎÒÏëдһϹØÓÚsocketµÄ±à³Ì¡£
ÏÈдһ¸öʱ¼ä·þÎñÆ÷°É£¬Ëû¼àÌý¶Ë¿Ú£¬²¢Çһ᷵»Ø ·þÎñÆ÷µÄʱ¼ä
server.py
#!/usr/bin/python
# Copyright (c) angelipin (angelipin@126.com)
import ......

python±Ê¼ÇÖ®ÕýÔò±í´ïʽ

 ÕýÔò±í´ïʽ
¾ßÌåµÄ²Î¿¼ÊֲᣬÕâÀï¼ÇÏÂһЩСÎÊÌ⣺
1¡¢re¶ÔÏóµÄ·½·¨
match    Match a regular expression pattern to the beginning of a string.
search   re.search(pattern, string, flags) flags:re.I re.M re.X re.S re.L re.U
sub      Substitute oc ......

(ת) pythonÓ¦ÓÃÁìÓò½éÉÜ

#---------------------תתתתתתתתתתתתתתתתתתתתתתת-------------------------------------------#
Python×÷ΪһÖÖ¹¦ÄÜÇ¿´óÇÒͨÓõıà³ÌÓïÑÔ¶ø¹ãÊܺÃÆÀ£¬Ëü¾ßÓзdz£ÇåÎúµÄÓï·¨Ìص㣬ÊÊÓÃÓÚ¶àÖÖ²Ù×÷ϵͳ£¬Ä¿Ç°ÔÚ¹ú¼ÊÉϷdz£Á÷ÐУ¬ÕýÔڵõ½Ô½À´Ô½¶àµÄÓ¦Óá£
 
¡¡¡¡ÏÂÃæ¾ÍÈÃÎÒÃÇÒ»ÆðÀ´¿´¿´ËüµÄÇ¿´ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ