pythonÕýÔò±í´ïʽ ÈçºÎÈ¡³öÒÔÏÂ×Ö·û´® ¶àл
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
ÓÃÕýÔò±í´ïʽȡ³ö ǰºó×ÖĸÏàͬµÄÊý¾Ý ½á¹ûÈçÏÂ:
111 ddd
лл~
Python code:
import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
p=re.compile(r'(\w)\1{2,}(\w+)(\w)\1{2,}')
m=re.finditer(p,s)
for i in m:
print i.group(2)
Âé·³Äܲ»ÄܽâÊÍһϠÎÒ¸Õ¸ÕÑо¿ÕýÔò±í´ïʽ ¶àл¸ßÈË
(\w)\1{2,}(\w+)(\w)\1{2,} ÓеãСÎÊÌâ
ÐÞÐÞ:
(\w)\1+(\w+)\1{2,}
Â¥Ö÷ûÓбí´ïÈ·È·µÄÒâ˼
"aaa111aaaa" => 111 ?? 111a?? »¹ÊDz»Æ¥Åä??
"aaaa111aaa" => 111 ?? a111?? »¹ÊDz»Æ¥Åä??
r'(\w)\1{2,}(\w+)(\w)\1{2,}' ¿ÉÒÔÓÅ»¯Îª r'(\w)\1{2,}(\w+)\1{3}'
ÕýÔòµÄÖªÊ¶ÍøÉÏ´ó°Ñ´ó°ÑµÄ£¬Ëæ±ãgoogleÒ»¸öÍêÕûµÄ¿´¿´¾ÍokÁË
dddddddddddddddddd
ѧϰÁË.....
Â¥Ö÷µÄÆ¥Å乿ÔòÊDz»ÊǾÍÊÇ×óÓҶԳƵÄÒ»¸ö×Ö·û´®£¬È¡ÖмäµÄ¶Ô³Æµã£¿
Python code:
import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
l=s.split(',')
p=re.compile(r'^(?P<balance>\w+)(?P<target>\w+)(?P=balance)$')
for item in l:
m=p.match(item)
if m != None:
print m.group('target')
(r'^(?P<balance>\w+)(?P<target>\w+)(?P=balance)$')<
Ïà¹ØÎÊ´ð£º
pythonºÍpyqtÒÔ¼°Eric4¶¼ÒѾÅäÖúÃÁË£¬´ò¿ªEric4д¸öpython³ÌÐò±ÈÈç¼òµ¥µÄ
print¡°hello£¬world¡±£¬Ôõô±àÒëÔËÐÐÁË£¬Start²Ëµ¥µÄËùÓÐÃüÁî¶¼³öÏÖºÍͼÖв¶àµÄ¶Ô»°¿ò£¬Ó¦µ±ÔõôÔËÐÐÁË£¿
Çó´ó¼ÒÖ¸½Ì
ûÓÐÈËÓà ......
Èç¹ûÒ»¶Î´úÂë
Python code:
#!/usr/bin/python2.5
from urllib2 import Request,urlopen,URLError
def check():
req = Request('http://www.google.com')
try:
res = urlopen(req).read()
......
http://www.cioage.com/art/200906/78173.htm
¾ÝϤ£¬¿¨°Í˹»ùʵÑéÊÒÉÏÖܼì²âµ½Ò»ÖÖ¹¥»÷Èû°àϵͳµÄжñÒâ³ÌÐò£¬¸Ã³ÌÐòµÄ¹¥»÷Ä¿±êÊÇÒ»¼ÒÓ¡¶ÈÄáÎ÷ÑÇÒÆ¶¯µç»°ÔËÓªÉ̵ÄÓû§¡£¸ÃľÂíÓÉÒ»ÖֽРPythonµÄ½Å±¾ÓïÑÔ±àд£¬Ëü» ......
֮ǰÎҵĵçÄÔÉϰ²×°ÁËIronPython2.0,ºó°²×°ShareDevelop3.0,²ÉÓÃĬÈÏÉèÖÃ
ÎÒÔÚShareDevelopÖн¨Á¢ÁËÒ»¸öĬÈϵÄPythonµÄ¿ØÖÆÌ¨»ò´°ÌåÏîÄ¿,ÔËÐÐʱ±¨´íÈçÏÂ:
µ÷ÊÔÆ÷Å׳öÒì³£System.IO.FileNotFoundException: ......
Ïñ C µÄ scanf() ÄÇÑù
±ÈÈç¶ÁÈë 1 2 3 a b c
ÿ´Î¶ÁÈëÒ»¸ö
ÏÂÃæÕâ¸öÓ¦¸ÃÊÇÄãÏëÒªµÄ°É£º
Python code:
>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......