¡¾ÇóÖú¡¿pythonÈçºÎʵÏÖ×Ö·û´®ºÍÊý×ÖµÄת»»
´ÓÎļþ¶ÁÈ¡³ö×Ö·û´® Òª°ÑÒ»²¿·ÖʵÏÖ++£¬
¾ÙÀý£ºAT005CC56£¬Òª°ÑATºóÃæµÄÊý×Ö++£¬¸Ä³É006£¬ÔÙд»ØÈ¥
Òª°Ñ×Ö·û´®×ª»»³ÉÊý×Ö£¬ÔÙת»ØÈ¥£¬Çó½Ì´óÏÀÈçºÎʵÏÖ£¬¶àл
ÕâÑùÊÇ·ñÂú×㣿£¡
Python code:
>>> STR
'AT005CC56'
>>> m = re.findall('[0-9]+',STR)
>>> m[0]=(int(m[0])+1).__str__().rjust(3, '0')
>>> s = re.sub(re.findall('[0-9]+',STR)[0], m[0], STR)
'AT006CC56'
ÓÃÕýÔò°É£º
Python code:
import re
a = 'AT005CC56'
reg = re.compile(r'AT(\d+?)[^\d]+?\d*')
match = reg.search(a)
if match is not None:
num = match.groups()[0]
format = 'AT%' + '0%dd' % len(num)
a = reg.sub(format % (int(num)+1), a)
print a
ÎÒµÄÓÐÒ»µãµãÎÊÌ⣬ÐÞÕýһϣº
Python code:
import re
a = 'AT005CC56'
reg = re.compile(r'AT(\d+?)[^\d]+?.*')
match = reg.search(a)
if match is not None:
num = match.groups()[0]
format = '%' + '0%dd' % len(num)
a= a.replace(num, format % (int(num)+1))
print a
import re
stram='abc12def000007bcdAB005ABC62b'
fi=re.findall(r'[0-9]+',stram)
for e
Ïà¹ØÎÊ´ð£º
ÇëÎÊÏ£¬ÎÒµÄÊÇpython2.5°²×°ÁËPILÄ£¿é£¬È»ºó±àд³ÌÐò´ò¿ª±¾»úÉϵÄÒ»¸öͼƬʱ£¬ÎªÊ²Ã´ÀϳöÏÖ´íÎóÄØ£¬ÀÏÊÇÕÒ²»µ½Í¼Æ¬£¬´íÎóÌáʾÈçÏ£ºFile "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......
ÎÒÏëÓÃpython½âÎöÍøÒ³ÖеÄurl ÔÚÏÂÔØ֮ǰ, ÎÒÏëÏÈ·¢Ò»¸öheadÇëÇó ²»ÐèÒªÏÂÔØÕû¸öÍøÒ³, ÏÈ»ñµÃ¸ÃÍøÕ¾µÄheadÐÅÏ¢, ¶ÁȡһЩÐÅÏ¢Ö®ºó ÔÚµ÷ÓÃÕâЩ¿âµÄread·½·¨À´¶ÁÈ¡Õû¸öÍøÒ³ ¸ÃÔõô²Ù×÷ÄØ ¶àл
°ï¶¥ÁË
ÓÐÈËÄÜÖ¸½ÌÒ» ......
ѧϰpythonµÄ7±¾Êé
°üÀ¨6±¾chm£¬Ò»±¾pdf×ÊÁÏ
¶ÔѧϰpythonÓкܴóµÄ°ïÖú
http://download.csdn.net/source/619791
¾«ÐÄËѼ¯£¬²»Òª»ý·Ö£¬ÄóöÀ´·ÖÏí
лл¥Ö÷£¬ÐÁ¿àÁË~
lz ×îºÃ°ÑÊéÃûºÍ¼òµ¥½éÉܼÓÉ ......
#coding:utf-8
import socket,time,sys
def proxy_server():
client_addr = 0
conn = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
conn.setsockopt ......
ÇëÎÊÎÒÓÐÕâÑùµÄ×Ö·û´® [[A:10, B:8, C:7]D:11, E:12, F:13], ÎÒ»¹ÓиönodeÀ࣬ ABCDEF¶¼ÊÇnodeÀàµÄ¶ÔÏó£¬ÎÒÒª½¨Á¢Ò»¿ÃÊ÷£¬R´ú±í¸ù£¬RÓÐÈý¸ö×Ó½ÚµãDEF£¬ DÓÖÓÐÈý¸ö×Ó½ÚµãABC£¬ ÓÐûÓкõÄÀý×Ó¿ÉÒÔѧϰһÏ°¢
È ......