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 continues to
take into account the needs of Python developers as Python matures.
XML, on the other hand, though strongly impacted by the ideas of a
small cadre of visionaries, has grown from standards-committee roots.
It has seen both quiet adoption and wrenching battles over its future.
Why bother putting the two technologies together?
Before the Python/XML combination, there seemed no easy or effective
way to work with XML in a distributed environment. Developers were
forced to rely on a variety of tools used in awkward combination with
one other. We used shell scripting and Perl to process text and
interact with the operating system, and then used Java XML API's for
processing XML and ......
·¢ÐÅÈË: TRAD (GFans), ÐÅÇø: NLP
±ê Ìâ: Ô´´£ºÊ¹ÓÃpythonµ÷ÓüÆËãËù·Ö´Ê
·¢ÐÅÕ¾: ˮľÉçÇø (Mon Nov 23 13:30:46 2009), Õ¾ÄÚ
´úÂëºÜ¼òµ¥£¬µ«ÎÒ×Ô¼ºÃþË÷ÁËÒ»ÏÂÎç,·¢³öÀ´¹²ÏíÒ»ÏÂ
°ÑÕâ¸öÎļþͬICTALAS30.DLL £¬DATAÎļþ¼Ð£¬Configure.xm l·ÅÔÚͬһ¸öĿ¼Ï¼´¿É¡£
python´úÂë
#coding:gb2312
from ctypes import *
dll=cdll.LoadLibrary("ICTCLAS30.dll")
dll.ICTCLAS_Init(c_char_p("."))
lpText = u"¼ÆËãËùººÓï´Ê·¨·ÖÎöϵͳICTCLASµ÷ÓòâÊÔ"
bSuccess = dll.ICTCLAS_ParagraphProcess(c_char_p(lpText), 1)
print c_char_p(bSuccess).value,lpText
dll.ICTCLAS_Exit()
--
¡ù À´Ô´:·Ë®Ä¾ÉçÇø http://newsmth.net·[from: 203.86.35.*] ......
PythonµÄ×Öµä²Ù×÷
PythonÌṩÁ˶àÖÖÓ¦ÓÃÓÚ×ÖµäµÄ²Ù×÷¡£ÒòΪ×ÖµäΪÈÝÆ÷£¬ÄÚ½¨lenº¯Êý¿ÉÒÔ½«×ֵ䵱×÷µ¥Ò»²ÎÊýʹÓÃÌýÇзµ»Ø×Öµä¶ÔÏóÖÐÏîÄ¿£¨¼ü£¯Öµ¶Ô£©µÄÊýÄ¿¡£
×Öµä»áÔ±
ÔÚPython2.2ÒÔ¼°ºóÃæ°æ±¾£¬DÖеÄkÔËËã·û¼ì²âÊÇ·ñ¶ÔÏókÊÇ×ÖµäDÖеļü¡£Èç¹ûÊÇ·µ»ØTrueÈç¹û²»ÊÇ·µ»ØFalse¡£ÏàËƵģ¬
Ë÷ÒýÒ»¸ö×Öµä
×ÖµäDÖеÄÖµÓëÏà¹ØµÄ¼ük±»Ë÷Òý±íʾΪ£ºD[k]¡£Ë÷Òý×ÖµäûÓеļü»áÒýÆðÒâÍâ¡£ÀýÈ磺
d = { 'x':42, 'y':3.14, 'z':7 }
d['x']
# 42
d['z']
# 7
d['a']
# raises exception
ƽÕû¸³Öµµ½Ò»¸öʹÓû¹²»ÔÚ×ÖµäÖеļüµÄË÷Òý£¨ÀýÈ磬D[newkey]=value£©ÊÇÒ»¸ö ......
ÖÐÎļò½é
¡¡¡¡Python (·¢Òô:[ 'paiθ(?)n; (US) 'paiθ?n ]n.òþÉߣ¬¾ÞÉß )£¬ÊÇÒ»ÖÖÃæÏò¶ÔÏóµÄ½âÊÍÐԵļÆËã»ú³ÌÐòÉè¼ÆÓïÑÔ£¬Ò²ÊÇÒ»ÖÖ¹¦ÄÜÇ¿´ó¶øÍêÉƵÄͨÓÃÐÍÓïÑÔ£¬ÒѾ¾ßÓÐÊ®¶àÄêµÄ·¢Õ¹ÀúÊ·£¬³ÉÊìÇÒÎȶ¨¡£Python ¾ßÓнű¾ÓïÑÔÖÐ×î·á¸»ºÍÇ¿´óµÄÀà¿â£¬×ãÒÔÖ§³Ö¾ø´ó¶àÊýÈÕ³£Ó¦Óá£ËüµÄÃû×ÖÀ´Ô´ÓÚÒ»¸öϲ¾ç,Ò²Ðí×î³õÉè¼ÆPythonÕâÖÖÓïÑÔµÄÈ˲¢Ã»ÓÐÏëµ½½ñÌìPython»áÔÚ¹¤ÒµºÍ¿ÆÑÐÉÏ»ñµÃÈç´Ë¹ã·ºµÄʹÓá£ÖøÃûµÄ×ÔÓÉÈí¼þ×÷ÕßEric RaymondÔÚËûµÄÎÄÕ¡¶ÈçºÎ³ÉΪһÃûºÚ¿Í¡·ÖУ¬½«PythonÁÐΪºÚ¿ÍÓ¦µ±Ñ§Ï°µÄËÄÖÖ±à³ÌÓïÑÔÖ®Ò»£¬²¢½¨ÒéÈËÃÇ´ÓPython¿ªÊ¼Ñ§Ï°±à³Ì¡£ÕâµÄÈ·ÊÇÒ»¸öÖпϵĽ¨Ò飬¶ÔÓÚÄÇЩ´ÓÀ´Ã»ÓÐѧϰ¹ý±à³Ì»òÕß²¢·Ç¼ÆËã»úרҵµÄ±à³ÌѧϰÕ߶øÑÔ£¬PythonÊÇ×îºÃµÄÑ¡ÔñÖ®Ò»¡£
¡¡¡¡
Ó¢Îļò½é
¡¡¡¡Python is an object-oriented explanation of computer programming languages, is a powerful and well-size-fits-all language, has been more than a decade of development, maturity and stability. Python scripting language with the most rich and powerful class library, enough to support the vast majority of day-to-day applications.
¡¡¡¡This language has ......
#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.²éÕÒ×Ö·û'
''
#strchr(
sStr1,
sStr2)
sStr1 =
'strchr'
sStr2 =
'r'
nPos =
sStr1.
index(
sStr2)
print
nPos
''
'4.±È½Ï×Ö·û´®'
''
#strcmp(
sStr1,
sStr2)
sStr1 =
'strchr'
sStr2 =
'strch'
print
cmp(
sStr1,
sStr2)
''
'5.ɨÃè×Ö·û´®ÊÇ·ñ°üº¬Ö¸¶¨µÄ×Ö·û'
''
#strspn(
sStr1,
sStr2)
sStr1 =
'12345678'
sStr2 =
'456'
#sStr1 and
chars both in
sStr1 and
sStr2
print
len(
sStr1 and
sStr2)
''
'6.×Ö·û´®³¤¶È'
''
#strlen(
sStr1)
sStr1 =
'strlen'
print
len(
sStr1)
''
'7.½«×Ö·û´®ÖеÄСд×Ö·ûת»»Îª´óд×Ö·û'
''
#strlwr(
sStr1)
sStr1 =
'JCstrlwr'
sStr1 =
sStr1.
upper(
)
print
sStr1
''
'8.×·¼ÓÖ¸¶¨³¤¶ÈµÄ×Ö·û´®'
''
#strncat(
sStr1,
sStr2,
n)
sStr1 =
......
http://www.itzn.cn/html/jiaoben/python-perl-VBA/200812/19-3283.html
×Ö·û´®ÊÇʹÓþ²Ì¬µÄ·½Ê½½øÐд洢£¬Ö»ÄܶÁ¶ø²»ÄÜÖ±½ÓÐÞ¸Ä×Ö·ûÄÚÈÝ¡£Ìرð½«Ò»¶Ñ¶Ô×Ö·û´®²¢ÔÚÒ»ÆðµÄʱºò£¬ËäÈ»¿ÉÒÔÖ±½ÓÏà¼Ó£¬Ìý˵ÕâÑùµÄËÙ¶ÈÆæÂý£¬Ö»ÓÐÓÃÆäËüº¯ÊýµÄ·½Ê½½øÐУ¬ºÃÔÚÒ²²»Ì«Âé·³¡£
±ÈÈçÓà print ','.join(datelist)
¾Í¿ÉÒÔ½«datelistÁбíÀïÃæµÄËùÓÐÏîÄ¿²¢³ÉÒ»¸ö×Ö·û´®£¬µ±È»Õâ¸ö±í´ïʽ»áÔÚÿһ¸öÏîÄ¿Öмä²åÈëÒ»¸ö¶ººÅ£¬ÕâÖÖ·½Ê½±ÈÓÃÑ»·µÄ·½Ê½¸ü¼ò½à¡£
ÈÕÆڵIJÙ×÷±ØÐëʹÓÃtime»òdatetime¿â
import time
>>> s="2006-1-2"
>>> time.strptime(s,"%Y-%m-%d)
ÕâÊǽ«×Ö·û´®¸ñʽµÄÈÕÆÚ¼°Ê±¼äת³ÉÈÕÆÚ¶ÔÏó
תÒå·û¶ÔÓ¦ÒâÒåÈçÏÂ
%a ±¾µØ¼ò»¯ÐÇÆÚÃû³Æ
%A ±¾µØÍêÕûÐÇÆÚÃû³Æ
%b ±¾µØ¼ò»¯µÄÔ·ÝÃû³Æ
%B ±¾µØÍêÕûµÄÔ·ÝÃû³Æ
%c ±¾µØÏàÓ¦µÄÈÕÆÚ±íʾºÍʱ¼ä±íʾ
%d ÔÂÄÚÖеÄÒ»Ì죨0-31£©
%H 24СʱÖÆСʱÊý£¨0-23£©
%I 12СʱÖÆСʱÊý£¨01-12£©
%j ÄêÄÚµÄÒ»Ì죨001-366£©
%m Ô·ݣ¨01-12£©
%M ·ÖÖÓÊý£¨00=59£©
%p ±¾µØA.M.»òP.M.µÄµÈ¼Û·û
%S Ã루00-59£©
%U Ò»ÄêÖеÄÐÇÆÚÊý£¨00-53£©ÐÇÆÚÌìΪÐÇÆڵĿªÊ¼
%w ÐÇÆÚ£¨0-6£©£ ......