使用正则表达式得到想要的字符串
import re str ='one11two22three3four4' pattern = re.compile(r'(\d+)') print(re.findall(pattern,str)) str ='one11two22three3four4' pattern = re.compile(r'(.+?)(\d+)') print(re.findall(pattern,str))
多多练习,爬虫的时候可以用到,能实现从哪里开始爬,爬到哪里
import re str ='one11two22three3four4' pattern = re.compile(r'(\d+)') print(re.findall(pattern,str)) str ='one11two22three3four4' pattern = re.compile(r'(.+?)(\d+)') print(re.findall(pattern,str))
多多练习,爬虫的时候可以用到,能实现从哪里开始爬,爬到哪里