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

PythonÖеıàÂë


pythonÖеıàÂë
Ô­ÎÄ£ºhttp://users.ir-lab.org/~liulong/blog/archives/001962.html
¼ÆËã»úÒÔ0,1¶þ½øÖÆÎ»À´´æ´¢ÐÅÏ¢,ËùÒÔ×Ö·ûÔÚ¼ÆËã»úÖеıíʾҲÊǶþ½øÖÆÎ»,ÄÇÿ¸ö×Ö·ûËù¶ÔÓ¦µÄ¶þ½øÖÆÎ»ÊÇʲô,ÔÚ¿ªÊ¼µÄ¼ÆËã»úÖÐÒòΪֻ¿¼ÂÇÓ¢Óï, ËùÒÔ²»³¬¹ý256¸ö×Ö·û,¼´ÓÃÒ»¸ö×Ö½Ú(8bit)¾Í×ã¿ÉÒÔ±íʾËùÓеÄ×Ö·û,Õâ¸ö¶ÔÓ¦¹ØÏµ¾ÍÊǶÔ×Ö·ûµÄ±àÂë,ÓÃÒ»¸öΨһµÄ×Ö½ÚÂëÀ´±íʾΨһµÄ×Ö·û.µ«ÊÇËæ ×ÅÒª¶Ôºº×Ö,ÈÕÓïµÈÆäËûÓïÑԵĴ¦Àí,ÕâÑùµÄ±àÂëÂú×ã²»ÁËÐèÇó,¸÷¸öµØÇø,¹ú¼Ò¾ÍÕë¶Ô¸÷×ÔµÄÓïÑÔ½¨Á¢ÁË×Ô¼ºµÄÒ»Ì×±àÂë,±ÈÈçgb2312,gbk,µÈ µÈ....ÕâÑùÊǽâ¾öÁËÒ»²¿·ÖÎÊÌâ,µ«ÊÇÕâ¾Í¸ø²»Í¬µÄϵͳ,ƽ̨֮¼äµÄ½»»¥Ôì³ÉÁ˺ܴóµÄÕϰ­,ΪÁ˽â¾ö´ËÎÊÌâ,³öÏÖÁËunicode,ËüΪÿÖÖÓïÑÔÖеÄÿ ¸ö×Ö·ûÉ趨ÁËͳһ²¢ÇÒΨһµÄ¶þ½øÖƱàÂ룬ÒÔÂú×ã¿çÓïÑÔ¡¢¿çƽ̨½øÐÐÎı¾»ù׼ת»»¡¢´¦ÀíµÄÒªÇó¡£Ã¿¸ö×Ö·û¶¼ÓÃÈô¸É¸ö×Ö½ÚÀ´±íʾ,ÕâÑù¾Í½â¾öÁËÆ½Ì¨,ϵͳ֮¼ä µÄ½»»¥ÎÊÌâ,µ«ÊÇunicodeÓиöȱµã,ÒòΪËüÿ¸ö×Ö·û¶¼ÓÃÈô¸É×Ö½ÚÀ´±íʾ,¼´Ê¹Êǵ¥×Ö½ÚµÄ×Ö·û,Õâ¾ÍÔì³ÉÁËʱ¼äºÍ¿Õ¼äÉϵÄÀË·Ñ,Òò´Ë³öÏÖÁËutf,ÊÇ Öмäת»»±àÂë,ÓÐutf8,utf16,utf7µÈ.³öÏÖÁ˶àÖÖ±àÂëÖ®ºó,ÔÚ²»Í¬µÄϵͳ,ƽ̨֮¼ä»ò³ÌÐò½Ó¿ÚÖÐ񻃾¼°µ½±àÂëµÄת»»,³£¼ûµÄת»»ÓÐ:
1.unicode->ÆäËü±àÂë
ÀýÈ磺aΪunicode±àÂë ҪתΪgb2312:a.encode('gb2312')
2.ÆäËü±àÂë->unicode
ÀýÈ磺aΪgb2312±àÂ룬ҪתΪunicode: unicode(a, 'gb2312')»òa.decode('gb2312')
3,±àÂë1 -> ±àÂë2
ÏÈתΪunicodeÔÙתΪ±àÂë2
Èçgb2312תutf8
unicode(a, 'gb2312').encode(utf-8)
ĿǰΪֹÎÒ²»ÖªµÀÈçºÎÅжÏÒ»¸ö×Ö·ûµÄ±àÂëÊǺÎÖÖ±àÂë,Ö»ÊÇ´Ó³ÌÐòÖÐÅ×Òì³£,µÈÆäËû·½Ê½À´ÅжÏ,µ«ÊÇÓпÉÒÔÅжÏÊÇ·ñÊÇunicodeµÄ·½·¨:
isinstance(s, str) ÓÃÀ´ÅжÏÊÇ·ñΪһ°ã×Ö·û´®
isinstance(s, unicode) ÓÃÀ´ÅжÏÊÇ·ñΪunicode
Èç¹ûÒª°ÑÒ»¶¨±àÂëµÄ×Ö·ûÐòÁÐдµ½ÎļþÀï,Ö»Òª°Ñ×Ö·ûÐòÁбàÂëΪËùÐè±àÂë¼´¿É,ÀýÈç:
l = 'ÁõÁú'
l = unicode(l, 'cp936')
l = l.encode('utf-8')
open('test.txt','w').write(l)
····ºÇºÇ£¬Unicode¾ÍÏñÒ»¸öƽ̨£¬°Ñ´ó¼Ò¶¼Í³Ò»µ½Ò»ÆðÁË¡£µ«ÊÇÓеãÀ˷ѿռ䰡£¬ËùÒÔ´ó¼Ò¾ö¶¨×Ô¼ºµ½ÁËͳһƽ̨֮ºóÔÙ¶¨ÖÆÒ»ÏÂÒ²²»´í¡£
---˳±ãÍÆ¼öÒ»¸ö¼ì²â±àÂëÀàÐ͵ĺö«Î÷codedet£ºhttp://chardet.feedparser.org/


Ïà¹ØÎĵµ£º

Ò»¸öɾ³ýÎļþµÄPython³ÌÐò

   PythonÊÇÒ»ÖÖÃæÏò¶ÔÏóµÄ½âÊÍÐԵļÆËã»ú³ÌÐòÉè¼ÆÓïÑÔ£¬Ò²ÊÇÒ»ÖÖ¹¦ÄÜÇ¿´ó¶øÍêÉÆµÄͨÓÃÐÍÓïÑÔ£¬ÒѾ­¾ßÓÐÊ®¶àÄêµÄ·¢Õ¹ÀúÊ·£¬³ÉÊìÇÒÎȶ¨¡£Python ¾ßÓнű¾ÓïÑÔÖÐ×î·á¸»ºÍÇ¿´óµÄÀà¿â£¬×ãÒÔÖ§³Ö¾ø´ó¶àÊýÈÕ³£Ó¦Óá£Ëü¾ßÓмòµ¥¡¢Ò×ѧ¡¢Ãâ·Ñ¡¢¿ªÔ´¡¢¿ÉÒÆÖ²ÐÔ¡¢½âÊÍÐÔ¡¢ÃæÏò¶ÔÏ󡢿ÉÀ©Õ¹ÐÔ¡¢¿ÉǶÈëÐÔÒÔ¼°·á¸»µÄ¿âµÈÌØÐÔ£¬ ......

Ò»¸öÅúÁ¿ÐÞ¸ÄÎļþÃûµÄPython³ÌÐò

 ¹ØÓÚPython³ÌÐòµÄÔËÐУ¬Æäʵһ¸öPython³ÌÐò¾ÍÏ൱ÓÚÒ»¸öÓ¦ÓóÌÐò£¬Ëü²»ÐèÒª¾­¹ý±àÒ룬ֻÐèÒªÓû§µçÄÔÉÏÃæ°²×°Python»·¾³¼´¿É¡£ÒªÔËÐÐÒ»¸öpy³ÌÐò£¬Ö±½ÓË«»÷Õâ¸öpyÎļþ¼´¿É¡£Ò»°ãÇé¿öÏ£¬Ã»ÓÐÌáʾÓû§ÊäÈë»ò¿ØÖÆÆÁÄ»ÏÔʾ£¬´ò¿ªÒ»¸öpyÎļþʱ»áͻȻÉÁÒ»ÏÂÂíÉϾÍÍ˳ö£¬ÕâÊÇÓÉÓÚ³ÌÐòÔËÐÐÒѾ­Íê³ÉÁË¡£ÈôÐèÒªÏÔʾ£¬ÔòÒªÌí¼ÓÒ» ......

PythonÍêÈ«ÐÂÊֽ̳Ì

×÷Õߣºtaowen, billrice
http://www.cnblogs.com/taowen/articles/11239.html
Lesson 1 ×¼±¸ºÃѧϰPythonµÄ»·¾³
ÏÂÔØµÄµØÖ·ÊÇ£º
www.python.org
ΪÁË´ó¼ÒµÄ·½±ã£¬ÎÒÔÚУÄÚ×÷ÁËcopy£º
http://10.1.204.2/tool/compiler&IDE/Python-2.3.2-1.exe
linux°æ±¾µÄÎҾͲ»ËµÁË£¬ÒòΪÈç¹ûÄãÄܹ»Ê¹ÓÃlinux²¢°²×°ºÃ˵Ã÷Äã¿ÉÒÔ ......

Python, Ruby Óë Groovy£¬Ë­ÓëÕù·æ£¿

 SleekEngine
Ëæ×żÆËã»úÓ²¼þµÄ¿ìËÙ·¢Õ¹£¬10ÄêǰÒòΪËÙ¶ÈÎÊÌâ¶ø±»Ú¸²¡µÄJavaÏÖÔÚ³ÉÁ˼ÆËã»úÁ÷ÑÔÓïÑÔÖеÄÀϴ󣬵«ÊÇËüÈ´ÈÔ±»ÈÏΪ¸´ÔÓ±¿ÖØ£¬½ü¼¸ÄêÀ´¶¯Ì¬Óï
ÑÔÈ´ÓкóÀ´¸ÏÉϵÄÇ÷ÊÆ£¬ÕÆÎÕÒ»ÃŶ¯Ì¬ÓïÑÔ³ÉÁ˳ÌÐòÔ±ÐèÒª¿¼ÂǵÄÊÂÒË¡£ ½üÆÚ½Ó´¥Á˼¸ÖÖÁ÷ÐеĶ¯Ì¬ÓïÑÔPython, Ruby,
Groovy£¬ËüÃÇÏà±È¾²Ì¬ÓïÑÔJava/C++À´Ëµ£¬´óÎ ......

²ËÄñѧPython£¨Ò»£©

   Ϊ³äʵ×Ô¼ºÄÇÆ½Ó¹µÄ֪ʶ¿â£¬´Ó½ñÌ쿪ʼ£¬Ñ§Ï°PythonÓïÑÔ¡£   Ì«¸ßÉîµÄ×ÊÁÏ¿´²»¶®£¬µ±Á˱¾×î¼òµ¥µÄPython¼òÃ÷½Ì³Ì£¬ÖÐÎİæchm¸ñʽµÄ¡£²»Ëµ·Ï»°ÁË£¬¿ªÊ¼½øÈëPythonµÄÊÀ½ç°É¡£ £¨Ò»£©°²×°Python    дÕâÆªÎÄÕÂʱ£¬PythonµÄ×îа汾ÊÇ3.1£¬ÎÒϲ»¶ÓÃ×îÐµģ¬¾ÍÏÂÁËа汾µÄ¡£Ò»Â·NextÏÂÈ¥£¬ÎÒµÄC ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ