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

Python×Ö·û´®±àÂë

ÔÚPythonÖÐÓÐÐ©ÌØÊâµÄµØ·½ÊÇ´æÔÚÁ½ÖÖ×Ö·û´®£¬·Ö±ðΪstrºÍunicode×Ö·û´®£¬ËûÃǶ¼¼Ì³Ð×Ôbasestring¡£
È磺s="hello world"£¬sΪstr£»us=u"hello world"£¬usΪunicode¡£
ʹÓÃhelp(str)ºÍhelp(unicode)¿ÉÒԲ鿴¸÷×Ô˵Ã÷£¬ËûÃǶ¼ÓÐdecode¡¢encode·½·¨£¬
decodeÓÃÓÚ½«str×Ö·û´®½âÂëΪunicode×Ö·û´®£¬
encodeÓÃÓÚ½«unicode×Ö·û´®±àÂëΪstr×Ö·û´®¡£
ÔÚÖ¸¶¨±àÂëÈçÏÂʱÓÐ
#-*- encoding: UTF-8 -*-
ʾÀý½âÎö£º
>>> s='hello ÊÀ½ç'          //sΪstrÀàÐÍ£¬utf-8±àÂë
>>> dutf8=s.decode('gbk')   //ÓëÔ´±àÂë²»·û£¬ÓÃgbk½âÂë»á³ö´í
>>> dgbk=s.decode('utf-8')  //½âÂëÕýÈ·
>>> us=dgbk.encode('gbk')   //±àÂëת»»ÕýÈ·£¬usΪutf-8±àÂë
×ܽ᣺
1¡¢unicode±àÂëΪÖÐת±àÂ룬±àÂë˳ÐòΪ£º
                 decode           encode
str (utf-8±àÂë)  ------>  unicode ------> str(gbk±àÂë»òÕ߯äËû±àÂë)
2¡¢ÒªÏÔʾºº×Ö±ØÐëÓÃunicode±àÂë;¾¶Óжþ
¡¡1.¡¡s.decode("utf-8")
¡¡2.¡¡u"×Ö·û´®"
3¡¢ÓÉÉÏ¿ÉÖª£¬ÒªÏëתÂëÕýÈ·£¬Ê×ÏȱØÐëÖªµÀת»»¶ÔÏóµÄÕýÈ·±àÂë¡£


Ïà¹ØÎĵµ£º

Python ǶÌ׺¯Êý Óë ±äÁ¿×÷ÓÃÓò

a=1
print id(a)
a=2
print id(a)
a=a+1
print id(a) 
-------------------------------------------------------------------------------------------------------------------------
t=6
def tt():
    global t
    t=t+1
    print t
print t
tt()
½ ......

python֮ǿ´óµÄÈÕ־ģ¿é¡¾×ª¡¿

1.¼òµ¥µÄ½«ÈÕÖ¾´òÓ¡µ½ÆÁÄ»

import
logging

logging.
debug(
'This is debug message'
)
logging.
info(
'This is info message'
)
logging.
warning(
'This is warning message'
)
 
ÆÁÄ»ÉÏ´òÓ¡:

WARNING:root:This is warning ......

¡¾×ª¡¿PythonʵÏÖµÄHMMÀà

#!/usr/bin/env python """
HMM module This module implements simple Hidden Markov Model class. It follows the description in
Chapter 6 of Jurafsky and Martin (2008) fairly closely, with one exception: in this
implementation, we assume that all states are initial states. @author: R ......

pythonʹÓÃÐĵÃ2

Ŀǰ±àÒëÆ÷£¨Êµ¼ÊÊÇ·­ÒëÆ÷£©ÏîÄ¿ÒѾ­Íê³É£¬¶ÔpythonµÄʹÓÃÓÐÁ˸üÉîµÄ¸ÐÊÜ¡£
³ýÁË֮ǰ˵µÄÒÔÍ⣬ÒÔÏÂÊDz¹³ä¼¸µã£¨ÍêÈ«ÊǸöÈË¿´·¨£©¡£
Ê×ÏÈÊÇpythonÏà¶Ô·¾¶¶ÁÈ¡ÅäÖÃÎļþºÍдÎļþÎÊÌ⣬Ïà¶Ô·¾¶ÔÚpythonÖеÄʹÓøújavaºÍC++²»Í¬¡£ËüÊÇÔÚÄǸöλÖÃÔËÐÐpy½Å±¾£¬¾Í°Ñµ±Ç°Â·¾¶×÷Ϊ¸ù·¾¶¡£È磺µ±ÔÚĿ¼AÏÂÔËÐÐÒ»¸öpy½Å±¾£¬ÄÇôĿ ......

Python IDE and GUI Framework for Windows

Pythonwin - Python IDE and GUI Framework for Windows.
Copyright 1994-2006 Mark Hammond
Python is Copyright (c) 2000-2008 ActiveState Software Inc.
Copyright (c) 2001-2008 Python Software Foundation.
All Rights Reserved.
Copyright (c) 2000 BeOpen.com.
All Rights Reserved.
Copyright (c) 1995-20 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ