python3怎么用re导出文本数据-创新互联

小编给大家分享一下python3怎么用re导出文本数据,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

创新互联公司专注于网站建设|网站建设维护|优化|托管以及网络推广,积累了大量的网站设计与制作经验,为许多企业提供了网站定制设计服务,案例作品覆盖成都搬家公司等行业。能根据企业所处的行业与销售的产品,结合品牌形象的塑造,量身定制品质网站。

文本内容如下,就是一个编译后的map,我想提取里面的symbol信息,地址,以及在哪些模块里面使用了

当下面有多行时,也就是在多个.o文件中使用时,怎么提取出每一个.o

表达式是:

_([a-zA-Z0-9_]+)\s+([a-z0-9A-Z]{8})\s+defined\s+in\s+[a-zA-Z0-9_]+.o\s+section\s+.+\n\s+used in\s+([a-zA-Z0-9_]+.o)\s*\n\s*(\w+.o)\n\s*(\w+.o)

问题1:


当需要匹配多个“ ******.o”时如何匹配

问题2:

如何把所有满足条件的都匹配出来,

_PfTORQ_r_ThermEffCorrMult 000fe417 defined in torqmall.o section .bss
used in torqmctl.o
torqmrat.o
_PeTORQ_GearState 000fe419 defined in torqmall.o section .bss
used in torq_meth_jac.o
torq_mulf_jac.o
torqmgve.o
torqmgvv.o
etcdmtps.o
_PeTORQ_GearStatePrev 000fe41a defined in torqmall.o section .bss
_PeTORQ_GearStateDsrd 000fe41b defined in torqmall.o section .bss
_VfTORQ_AXIS_RPM_W_11Brk 000fe41c defined in torqmall.o section .bss
used in torqmdes.o
tqdrmall.o

解决方法:


 re.findall(pattern, string, flags=0)

范例:

>>> text = "He was carefully disguised but captured quickly by police."
>>> re.findall(r"\w+ly", text)
['carefully', 'quickly']

测试:


In [1]: yourstr="""_PfTORQ_r_ThermEffCorrMult 000fe417 defined in torqmall.o section .bss
used in torqmctl.o
torqmrat.o
_PeTORQ_GearState 000fe419 defined in torqmall.o section .bss
used in torq_meth_jac.o
torq_mulf_jac.o
torqmgve.o
torqmgvv.o
etcdmtps.o
_PeTORQ_GearStatePrev 000fe41a defined in torqmall.o section .bss
_PeTORQ_GearStateDsrd 000fe41b defined in torqmall.o section .bss
_VfTORQ_AXIS_RPM_W_11Brk 000fe41c defined in torqmall.o section .bss
used in torqmdes.o
tqdrmall.o"""
 
In [2]: re.findall('\w+\.o',yourstr)
Out[2]:
['torqmall.o',
 'torqmctl.o',
 'torqmrat.o',
 'torqmall.o',
 'torq_meth_jac.o',
 'torq_mulf_jac.o',
 'torqmgve.o',
 'torqmgvv.o',
 'etcdmtps.o',
 'torqmall.o',
 'torqmall.o',
 'torqmall.o',
 'torqmdes.o',
 'tqdrmall.o']

以上是python3怎么用re导出文本数据的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!

网页标题:python3怎么用re导出文本数据-创新互联
网页网址:https://www.cdcxhl.com/article30/eeppo.html

成都网站建设公司_创新互联,为您提供标签优化网站设计公司静态网站网站建设网站收录品牌网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

营销型网站建设