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)
Ïà¹ØÎĵµ£º
import Queue, threading, sys
from threading import Thread
import time,urllib
# working thread
class Worker(Thread):
worker_count = 0
def __init__( self, workQueue, resultQueue, timeout = 0, **kwds):
Thread.__init__( self, **kwds ) ......
Õâ¸öËãÊÇC++ǶÈëpython°É£¬ÀûÓÃpythonʵÏÖÏÔʾºÍʼþ´¦Àí£¬C++ʵÏÖÂß¼
ÒÔºóÓÐʱ¼äÒ²»á·´¹ýÀ´ÊÔÊÔ£º£©
import pygame
import sys
import os
import ctypes
def cur_file_dir():
#»ñÈ¡½Å±¾Â·¾¶
path = sys.path[0]
#ÅжÏΪ½Å±¾Îļþ»¹ÊÇpy2exe±àÒëºóµÄÎļþ£¬Èç¹ûÊǽű¾Îļþ£¬Ôò·µ»ØµÄÊǽű¾µÄÄ¿Â ......
Python-String-Function
×Ö·û´®ÖÐ×Ö·û´óСдµÄ±ä»»£º
* S.lower() #Сд
* S.upper() #´óд
* S.swapcase() #´óСд»¥»»
* S.capitalize() #Ê××Öĸ´óд
&n ......
http://www.itzn.cn/html/jiaoben/python-perl-VBA/200812/19-3283.html
×Ö·û´®ÊÇʹÓþ²Ì¬µÄ·½Ê½½øÐд洢£¬Ö»ÄܶÁ¶ø²»ÄÜÖ±½ÓÐÞ¸Ä×Ö·ûÄÚÈÝ¡£Ìرð½«Ò»¶Ñ¶Ô×Ö·û´®²¢ÔÚÒ»ÆðµÄʱºò£¬ËäÈ»¿ÉÒÔÖ±½ÓÏà¼Ó£¬Ìý˵ÕâÑùµÄËÙ¶ÈÆæÂý£¬Ö»ÓÐÓÃÆäËüº¯ÊýµÄ·½Ê½½øÐУ¬ºÃÔÚÒ²²»Ì«Âé·³¡£
±ÈÈçÓà print ','.join(datelist)
¾Í¿ÉÒÔ½«date ......
Ê×ÏÈÒª¸ãÇå³þ£¬×Ö·û´®ÔÚPythonÄÚ²¿µÄ±íʾÊÇunicode±àÂ룬Òò´Ë£¬ÔÚ×ö±àÂëת»»Ê±£¬Í¨³£ÐèÒªÒÔunicode×÷ΪÖмä±àÂ룬¼´ÏȽ«ÆäËû±àÂëµÄ×Ö·û´®½âÂ루decode£©³Éunicode£¬ÔÙ´Óunicode±àÂ루encode£©³ÉÁíÒ»ÖÖ±àÂë¡£
decodeµÄ×÷ÓÃÊǽ«ÆäËû±àÂëµÄ×Ö·û´®×ª»»³Éunicode±àÂ룬Èçstr1.decode('gb2312')£¬±íʾ½«gb2312±àÂëµÄ×Ö· ......