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

python ÅжÏÊDz»ÊÇÖÐÎÄ×Ö

 ÏÂÃæÕâ¸öС¹¤¾ß°üº¬ÁË ÅжÏunicodeÊÇ·ñÊǺº×Ö£¬Êý×Ö£¬Ó¢ÎÄ£¬»òÕ߯äËû×Ö·û¡£ È«½Ç·ûºÅת°ë½Ç·ûºÅ¡£ unicode×Ö·û´®¹éÒ»»¯µÈ¹¤×÷¡£ »¹ÓÐÒ»¸öÄÜ´¦Àí¶àÒô×ֵĺº×ÖתƴÒôµÄ³ÌÐò£¬»¹ÔÚÕûÀíÖС£
 
#!/usr/bin/env python
# -*- coding:GBK -*-
"""ºº×Ö´¦ÀíµÄ¹¤¾ß:
ÅжÏunicodeÊÇ·ñÊǺº×Ö£¬Êý×Ö£¬Ó¢ÎÄ£¬»òÕ߯äËû×Ö·û¡£
È«½Ç·ûºÅת°ë½Ç·ûºÅ¡£"""
__author__="internetsweeper <zhengbin0713@gmail.com>"
__date__="2007-08-04"
def is_chinese(uchar):
"""ÅжÏÒ»¸öunicodeÊÇ·ñÊǺº×Ö"""
if uchar >= u'\u4e00' and uchar<=u'\u9fa5':
return True
else:
return False
def is_number(uchar):
"""ÅжÏÒ»¸öunicodeÊÇ·ñÊÇÊý×Ö"""
if uchar >= u'\u0030' and uchar<=u'\u0039':
return True
else:
return False
def is_alphabet(uchar):
"""ÅжÏÒ»¸öunicodeÊÇ·ñÊÇÓ¢ÎÄ×Öĸ"""
if (uchar >= u'\u0041' and uchar<=u'\u005a') or (uchar >= u'\u0061' and uchar<=u'\u007a'):
return True
else:
return False
def is_other(uchar):
"""ÅжÏÊÇ·ñ·Çºº×Ö£¬Êý×ÖºÍÓ¢ÎÄ×Ö·û"""
if not (is_chinese(uchar) or is_number(uchar) or is_alphabet(uchar)):
return True
else:
return False
def B2Q(uchar):
"""°ë½Çתȫ½Ç"""
inside_code=ord(uchar)
if inside_code<0x0020 or inside_code>0x7e: #²»Êǰë½Ç×Ö·û¾Í·µ»ØÔ­À´µÄ×Ö·û
return uchar
if inside_code==0x0020: #³ýÁ˿ոñÆäËûµÄÈ«½Ç°ë½ÇµÄ¹«Ê½Îª:°ë½Ç=È«½Ç-0xfee0
inside_code=0x3000
else:
inside_code+=0xfee0
return unichr(inside_code)
def Q2B(uchar):
"""È«½Çת°ë½Ç"""
inside_code=ord(uchar)


Ïà¹ØÎĵµ£º

Python¼¸ÖÖ²¢·¢ÊµÏÖ·½°¸µÄÐÔÄܱȽÏ

 
#!/Library/Frameworks/Python.framework/Versions/2.5/bin/python
# encoding: utf-8
import sys, time
import thread
 
SLEEP_TIME = 0.0001
 
def run_benchmark(n, m):
    # print(">> Python 2.5.1, stackless 3.1b3 here (N=%d, M=%d)!\n" % (n, m))
    lock ......

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

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

Python & XML


Chapter 1
Python and XML
Python and XML are two very different animals, each with a rich
history. Python is a full-scale programming language that has grown
from scripting world roots in a very organic way, through the vision
and guidance of Python's inventor, Guido van Rossum. Guido continue ......

PythonÈÕÆÚ²Ù×÷ѧϰ±Ê¼Ç

 http://www.itzn.cn/html/jiaoben/python-perl-VBA/200812/19-3283.html
×Ö·û´®ÊÇʹÓþ²Ì¬µÄ·½Ê½½øÐд洢£¬Ö»ÄܶÁ¶ø²»ÄÜÖ±½ÓÐÞ¸Ä×Ö·ûÄÚÈÝ¡£Ìرð½«Ò»¶Ñ¶Ô×Ö·û´®²¢ÔÚÒ»ÆðµÄʱºò£¬ËäÈ»¿ÉÒÔÖ±½ÓÏà¼Ó£¬Ìý˵ÕâÑùµÄËÙ¶ÈÆæÂý£¬Ö»ÓÐÓÃÆäËüº¯ÊýµÄ·½Ê½½øÐУ¬ºÃÔÚÒ²²»Ì«Âé·³¡£
±ÈÈçÓà print ','.join(datelist)
¾Í¿ÉÒÔ½«date ......

Python×Ö·û´®µÄencodeÓëdecode

 
Ê×ÏÈÒª¸ãÇå³þ£¬×Ö·û´®ÔÚPythonÄÚ²¿µÄ±íʾÊÇunicode±àÂ룬Òò´Ë£¬ÔÚ×ö±àÂëת»»Ê±£¬Í¨³£ÐèÒªÒÔunicode×÷ΪÖмä±àÂ룬¼´ÏȽ«ÆäËû±àÂëµÄ×Ö·û´®½âÂ루decode£©³Éunicode£¬ÔÙ´Óunicode±àÂ루encode£©³ÉÁíÒ»ÖÖ±àÂë¡£
decodeµÄ×÷ÓÃÊǽ«ÆäËû±àÂëµÄ×Ö·û´®×ª»»³Éunicode±àÂ룬Èçstr1.decode('gb2312')£¬±íʾ½«gb2312±àÂëµÄ×Ö· ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ