.re:(网上摘)
import re
pattern = re.compile("forum\/(\d*)\/topic\/(\d*)")
res = pattern.search('forum/135/topic/794150').groups()
print res[0],res[1]
.re:(网上摘)
import re
pattern = re.compile("forum\/(\d*)\/topic\/(\d*)")
res = pattern.search('forum/135/topic/794150').groups()
print res[0],res[1]
转载于:https://www.cnblogs.com/yuchenkit/p/5323960.html