Python怎么提取出字符串中间的文本 文本如下['page:200">最后页'] 我要提取出中间的数字 该怎么做 10
1个回答
展开全部
Python 2.7.12 (default, Oct 6 2016, 23:31:29)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s='page:200">最后页'
>>> filter(lambda x:x.isdigit(),s)
'200'
>>> import re
>>> re.sub("\D", "", s)
'200'
>>> re.findall(r'(\w*\d+)\w*',s)
['200']
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s='page:200">最后页'
>>> filter(lambda x:x.isdigit(),s)
'200'
>>> import re
>>> re.sub("\D", "", s)
'200'
>>> re.findall(r'(\w*\d+)\w*',s)
['200']
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询