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

PYTHONÉèÖÃĬÈÏÓïÑÔ±àÂë

ת×Ô http://www.javaeye.com/topic/561786
Ô­Ìû£ºhttp://www.cnblogs.com/jingleguo/archive/2008/06/02/1211820.html
µ±pythonÖм䴦Àí·ÇASCII±àÂëʱ£¬¾­³£»á³öÏÖÈçÏ´íÎó£º
UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128)
0x??Êdz¬³ö128µÄÊý×Ö£¬pythonÔÚĬÈϵÄÇé¿öÏÂÈÏΪÓïÑԵıàÂëÊÇascii±àÂ룬ËùÒÔÎÞ·¨´¦ÀíÆäËû±àÂ룬ÐèÒªÉèÖÃpythonµÄĬÈϱàÂëΪËùÐèÒªµÄ±àÂë¡£
Ò»¸ö½â¾öµÄ·½°¸ÊÇÔÚ´úÂëÖÐÌí¼Ó£º
import sys
reload(sys)
sys.setdefaultencoding('gb2312')
ÁíÒ»¸ö·½°¸ÊÇÔÚpythonµÄLib\site-packagesÎļþ¼ÐÏÂн¨Ò»¸ösitecustomize.py
Îļþ£¨sitecustomize.py is a special script; Python will try to import it on startup, so any code in it will be run automatically.£©£¬ÊäÈ룺
import sys
sys.setdefaultencoding('gb2312')
ÕâÑù¾ÍÄܹ»×Ô¶¯µÄÉèÖñàÂëÁË¡£
ps£º
1. utf8µÄ±àÂëÊÇ£ºutf-8
2. ²âÊÔÒѾ­³É¹¦µÄ·½·¨£º
>>> import sys
>>> sys.getdefaultencoding()


Ïà¹ØÎĵµ£º

[ת]Python: python±àÂëÎÊÌâ

ÕâÊÇÒ»¸öÎÒÃÇÔÚ´¦ÀíÖÐÎÄʱ, ¾­³£Óöµ½µÄÎÊÌâ.
pythonÀïÃæ»ù±¾ÉÏÒª¿¼ÂÇÈýÖÖ±àÂë¸ñʽ
1 Ô´Îļþ±àÂë
ÔÚÎļþÍ·²¿Ê¹ÓÃcodingÉùÃ÷¡£¸æËßpython½âÊÍÆ÷¸Ã´úÂëÎļþËùʹÓõÄ×Ö·û¼¯¡£
#/usr/bin/python
#coding: utf8
2 ÄÚ²¿±àÂë
´úÂëÎļþÖеÄ×Ö·û´®£¬¾­¹ýdecodeÒԺ󣬱»×ª»»ÎªÍ³Ò»µÄunicode¸ñʽµÄÄÚ²¿Êý¾Ý£¬ÀàËÆÓÚu'*'¡£unic ......

Python 3 ³õ̽£¬µÚ 1 ²¿·Ö: Python 3 µÄÐÂÌØÐÔ

Python 3 ÊÇ Guido van Rossum ¹¦ÄÜÇ¿´óµÄͨÓñà³ÌÓïÑÔµÄ×îа汾¡£ËüËäÈ»´òÆÆÁËÓë 2.x °æ±¾µÄÏòºó¼æÈÝÐÔ£¬µ«È´ÇåÀíÁËijЩÓï·¨·½ÃæµÄÎÊÌâ¡£±¾ÎÄÊÇϵÁÐÎÄÕÂÖеĵÚһƪ£¬½éÉÜÁËÓ°Ïì¸ÃÓïÑÔ¼°Ïòºó¼æÈÝÐԵĸ÷Öֱ仯£¬²¢ÇÒ»¹ÌṩÁËÐÂÌØÐԵļ¸¸öÀý×Ó¡£
Python °æ±¾ 3£¬Ò²±»³ÆΪ Python 3000 »ò Py3K£¨·ÂЧ Microsoft® Windows ......

python Ö´ÐÐϵͳÃüÁî±È½Ï

תÔØ×Ô£ºhttp://purpen.javaeye.com/blog/98095
python Ö´ÐÐϵͳÃüÁî±È½Ï
¹Ø¼ü×Ö: python os system ϵͳÃüÁî
Ôڴ˱ȽÏÒ»ÏÂÁ½ÖÖ·½·¨Ö´ÐÐϵͳÃüÁîµÄ·½·¨,ÒÔ·½±ãÓÚÈÕºóÔËÓÃ:(
1. os.system()
system(command) -> exit_status  
      
Execute the  ......

cÅÌÕûÀí Python½Å±¾

ÄÜÕûÀí´ó²¿·ÖÎÞÓÃÎļþ
#!/usr/bin/python
#syscleaner.py
import os
import os.path
#delete files and directory recursively
def itedel(dir):
print('in dir :'+dir)
for doc in os.listdir(dir):
try:
if(os.path.isdir(doc)):
itedel(dir+'\\'+doc)
......

PythonºÍRubyµÄ¶Ô±È£¬¾ÀÕýһЩÎó½â

PythonºÍRubyµÄ¶Ô±È£¬¾ÀÕýһЩÎó½â
ÏÂÃæÊÇÎÒÔÚ¿´Á½Æª¹ØÓÚPythonºÍRuby¶Ô±ÈµÄÎÄÕÂʱ£¬Ëù×÷µÄ¾ÀÕý£¬Ô­ÎĶ¼Êǹ㷺Á÷Ðеģ¬±È½ÏºÃÕÒ¡£
------------------------------------------------------
¡¶rubyºÍpythonµÄ±È½Ï¡·¸üÕýÒ»µãÊÂÇé
1¡¢Îĵµ¡¢¿ªÔ´ÏîÄ¿¡¢¿âÖ§³Ö£¬ÕâЩ¶«Î÷Ruby²»Òª¸úPython±È£¬²»ÊǼ¸¸öÊýÁ¿¼¶µÄÎÊÌ⣬ºÎ±ØÃ²Ë ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ