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

python ÖÐÎÄÂÒÂë ÎÊÌâÉîÈë·ÖÎö

 
ת×Ô:http://hi.baidu.com/%C1%EE%BA%FC%CF%F3/blog/item/efb76fb7f0411dc437d3ca20.html
 
ÔÚ±¾ÎÄÖУ¬ÒÔ'¹þ'À´½âÊÍ×÷ʾÀý½âÊÍËùÓеÄÎÊÌ⣬“¹þ”µÄ¸÷ÖÖ±àÂëÈçÏ£º
  1. UNICODE (UTF8-16)£¬C854£»
  2£® UTF-8£¬E59388£»
  3£® GBK£¬B9FE¡£
Ò»¡¢pythonÖеÄstrºÍunicode
Ò»Ö±ÒÔÀ´£¬pythonÖеÄÖÐÎıàÂë¾ÍÊÇÒ»¸ö¼«ÎªÍ·´óµÄÎÊÌ⣬¾­³£Å׳ö±àÂëת»»µÄÒì³££¬pythonÖеÄstrºÍunicodeµ½µ×ÊÇÒ»¸öʲô¶«Î÷ÄØ£¿
ÔÚpythonÖÐÌáµ½unicode£¬Ò»°ãÖ¸µÄÊÇunicode¶ÔÏó£¬ÀýÈç'¹þ¹þ'µÄunicode¶ÔÏóΪ
u'\u54c8\u54c8'
¶østr£¬ÊÇÒ»¸ö×Ö½ÚÊý×飬Õâ¸ö×Ö½ÚÊý×é±íʾµÄÊǶÔunicode¶ÔÏó±àÂë(¿ÉÒÔÊÇutf-8¡¢gbk¡¢cp936¡¢GB2312)ºóµÄ´æ´¢µÄ¸ñʽ¡£ÕâÀïËü½ö½öÊÇÒ»¸ö×Ö½ÚÁ÷£¬Ã»ÓÐÆäËüµÄº¬Ò壬Èç¹ûÄãÏëʹÕâ¸ö×Ö½ÚÁ÷ÏÔʾµÄÄÚÈÝÓÐÒâÒ壬¾Í±ØÐëÓÃÕýÈ·µÄ±àÂë¸ñʽ£¬½âÂëÏÔʾ¡£
ÀýÈ磺
¶ÔÓÚunicode¶ÔÏó¹þ¹þ½øÐбàÂ룬±àÂë³É
Ò»¸öutf-8±àÂëµÄstr£­s_utf8,s_utf8¾ÍÊÇÊÇÒ»¸ö×Ö½ÚÊý×飬´æ·ÅµÄ¾ÍÊÇ'\xe5\x93\x88\xe5\x93\x88'£¬µ«ÊÇÕâ
½ö½öÊÇÒ»¸ö×Ö½ÚÊý×飬Èç¹ûÄãÏ뽫Ëüͨ¹ýprintÓï¾äÊä³ö³É¹þ¹þ£¬ÄÇÄã¾ÍʧÍûÁË£¬ÎªÊ²Ã´ÄØ£¿
ÒòΪprintÓï¾äËüµÄʵÏÖÊǽ«ÒªÊä³öµÄÄÚÈÝ
´«ËÍÁ˲Ù×÷ϵͳ£¬²Ù×÷ϵͳ»á¸ù¾ÝϵͳµÄ±àÂë¶ÔÊäÈëµÄ×Ö½ÚÁ÷½øÐбàÂ룬Õâ¾Í½âÊÍÁËΪʲôutf-8¸ñʽµÄ×Ö·û´®“¹þ¹þ”£¬Êä³öµÄÊÇ“鍝堝搱”£¬ÒòΪ
'\xe5\x93\x88\xe5\x93\x88'ÓÃGB2312È¥½âÊÍ£¬ÆäÏÔʾµÄ³öÀ´¾ÍÊÇ“鍝堝搱”¡£ÕâÀïÔÙÇ¿µ÷һϣ¬str¼Ç¼µÄÊÇ×Ö½ÚÊý×飬ֻ
ÊÇijÖÖ±àÂëµÄ´æ´¢¸ñʽ£¬ÖÁÓÚÊä³öµ½Îļþ»òÊÇ´òÓ¡³öÀ´ÊÇʲô¸ñʽ£¬ÍêÈ«È¡¾öÓÚÆä½âÂëµÄ±àÂ뽫Ëü½âÂë³ÉʲôÑù×Ó¡£
ÕâÀïÔÙ¶Ôprint½øÐÐÒ»µã²¹³ä˵Ã÷£ºµ±½«Ò»¸öunicode¶ÔÏ󴫸øprintʱ£¬ÔÚÄÚ²¿»á½«¸Ãunicode¶ÔÏó½øÐÐÒ»´Îת»»£¬×ª»»³É±¾µØµÄĬÈϱàÂ루Õâ½öÊǸöÈ˲²⣩
¶þ¡¢strºÍunicode¶ÔÏóµÄת»»
strºÍunicode¶ÔÏóµÄת»»£¬Í¨¹ýencodeºÍdecodeʵÏÖ£¬¾ßÌåʹÓÃÈçÏ£º
½«GBK'¹þ¹þ'ת»»³Éunicode£¬È»ºóÔÙת»»³ÉUTF8
Èý¡¢Setdefaultencoding
ÈçÉÏͼµÄÑÝʾ´úÂëËùʾ£º
µ±°Ñs(gbk×Ö·û´®)Ö±½Ó±àÂë³Éutf-8µÄʱºò£¬½«Å׳öÒì³££¬µ«ÊÇͨ¹ýµ÷ÓÃÈçÏ´úÂ룺
import sys
reload(sys)
sys.setdefaultencoding('gbk')
ºó¾Í¿ÉÒÔת»»³É¹¦£¬ÎªÊ²Ã´ÄØ£¿ÔÚpythonÖÐstrºÍunicodeÔÚ±àÂëºÍ½âÂë¹ý³ÌÖУ¬Èç¹û½«Ò»¸östrÖ±½Ó±àÂë³ÉÁíÒ»ÖÖ±àÂ룬»áÏÈ°Ñstr


Ïà¹ØÎĵµ£º

opencv python cool

µ±Äê×ö±ÏÒµÂÛÎĵÄʱºòopenCV¾ÍÏñÊÇÎÒµÄÈðÊ¿¾üµ¶£¬Ì«ÓиÐÇéÁË¡£Èç½ñÓÃÁËÒ»Äê¶àµÄpython£¬·¢ÏÖopenCVÒ²ÓÐpython°æ±¾ÁË£¬ÕæÊÇÌ«¿áÁË£¡µ±È»pythonÔÚ´¦ÀíͼÏñʱ»¹¿ÉÒÔÓÃÆäËü¿âÀýÈçPIL(Python Imaging Library )£¬Ò»ÖÖÇáÁ¿¼¶µÄͼÏñ¿â¡£Ä¿Ç°openCV1.0°æ±¾¶ÔÓ¦µÄpython°æ±¾Îª2.5£¬openCV2.0¶ÔÓ¦python 2.6¡£
¸½Â¼£º
1. һƪ½éÉÜͼ ......

python ¶íÂÞ˹·½¿é

Õâ¸öËãÊÇC++ǶÈëpython°É£¬ÀûÓÃpythonʵÏÖÏÔʾºÍʼþ´¦Àí£¬C++ʵÏÖÂß¼­
ÒÔºóÓÐʱ¼äÒ²»á·´¹ýÀ´ÊÔÊÔ£º£© 
import pygame
import sys
import os
import ctypes
def cur_file_dir():
#»ñÈ¡½Å±¾Â·¾¶
path = sys.path[0]
#ÅжÏΪ½Å±¾Îļþ»¹ÊÇpy2exe±àÒëºóµÄÎļþ£¬Èç¹ûÊǽű¾Îļþ£¬Ôò·µ»ØµÄÊǽű¾µÄÄ¿Â ......

Python µÄCÓïÑÔÀ©Õ¹

²Ù×÷ϵͳ£ºlinux debian 4.0£¬ python°æ±¾2.5
s1:°²×°python2.5-dev¡£ÒòΪPython.hÊÇÔÚdev°üÖвÅÓС£
test@debian:~/test_python_c$ aptitude search python2.5-dev
p python2.5-dev - Header files and a static library for Python.
test@debian:~/test_python_c$ sudo aptitude install python2 ......

[ת]ʹÓÃpythonµ÷ÓüÆËãËù·Ö´Ê

·¢ÐÅÈË: TRAD (GFans), ÐÅÇø: NLP
±ê  Ìâ: Ô­´´£ºÊ¹ÓÃpythonµ÷ÓüÆËãËù·Ö´Ê
·¢ÐÅÕ¾: ˮľÉçÇø (Mon Nov 23 13:30:46 2009), Õ¾ÄÚ
´úÂëºÜ¼òµ¥£¬µ«ÎÒ×Ô¼ºÃþË÷ÁËÒ»ÏÂÎç,·¢³öÀ´¹²ÏíÒ»ÏÂ
°ÑÕâ¸öÎļþͬICTALAS30.DLL £¬DATAÎļþ¼Ð£¬Configure.xm l·ÅÔÚͬһ¸öĿ¼Ï¼´¿É¡£
python´úÂë
#coding:gb2312 
from cty ......

Python×Ö·û´®²Ù×÷

 #Python×Ö·û´®²Ù×÷
''
'1.¸´ÖÆ×Ö·û´®'
''
#strcpy(
sStr1,
sStr2)
sStr1 =
'strcpy'
sStr2 =
sStr1
sStr1 =
'strcpy2'
print
sStr2
''
'2.Á¬½Ó×Ö·û´®'
''
#strcat(
sStr1,
sStr2)
sStr1 =
'strcat'
sStr2 =
'append'
sStr1 +
=
sStr2
print
sStr1
''
'3.²éÕÒ×Ö·û'
''
#strc ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ