python3怎么用re導出文本數(shù)據(jù)-創(chuàng)新互聯(lián)

小編給大家分享一下python3怎么用re導出文本數(shù)據(jù),相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)公司專注于網(wǎng)站建設|網(wǎng)站建設維護|優(yōu)化|托管以及網(wǎng)絡推廣,積累了大量的網(wǎng)站設計與制作經(jīng)驗,為許多企業(yè)提供了網(wǎng)站定制設計服務,案例作品覆蓋成都搬家公司等行業(yè)。能根據(jù)企業(yè)所處的行業(yè)與銷售的產(chǎn)品,結(jié)合品牌形象的塑造,量身定制品質(zhì)網(wǎng)站。

文本內(nèi)容如下,就是一個編譯后的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導出文本數(shù)據(jù)的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)頁標題:python3怎么用re導出文本數(shù)據(jù)-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://muchs.cn/article30/eeppo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供標簽優(yōu)化、網(wǎng)站設計公司、靜態(tài)網(wǎng)站、網(wǎng)站建設網(wǎng)站收錄、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設