日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
創(chuàng)新互聯(lián)Python教程:python3如何用re導(dǎo)出文本數(shù)據(jù)?

在小學(xué)做題的時(shí)候,如果題目中有相同的數(shù)值,我們還可以通過(guò)人工比對(duì)查找出來(lái)。不過(guò)現(xiàn)在要用電腦處理的數(shù)據(jù)很多,我們需要借助某種工具,來(lái)幫我們篩選出重復(fù)的數(shù)據(jù)或是文件名。那么學(xué)了python的我們有沒(méi)有什么解決辦法呢?今天小編就教大家用re導(dǎo)出文本數(shù)據(jù),具體舉例如下:


文本內(nèi)容如下,就是一個(gè)編譯后的map,我想提取里面的symbol信息,地址,以及在哪些模塊里面使用了

當(dāng)下面有多行時(shí),也就是在多個(gè).o文件中使用時(shí),怎么提取出每一個(gè).o

表達(dá)式是:

_([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)

問(wèn)題1:

當(dāng)需要匹配多個(gè)“ ******.o”時(shí)如何匹配

問(wèn)題2:

如何把所有滿(mǎn)足條件的都匹配出來(lái),

_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']

測(cè)試:

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']

看完后小伙伴們會(huì)發(fā)現(xiàn),我們想要的.o的結(jié)果已經(jīng)出來(lái)啦,說(shuō)明re.findall針對(duì)此類(lèi)問(wèn)題的解決有效果哦~更多Python學(xué)習(xí)推薦:PyThon學(xué)習(xí)網(wǎng)教學(xué)中心。


網(wǎng)站名稱(chēng):創(chuàng)新互聯(lián)Python教程:python3如何用re導(dǎo)出文本數(shù)據(jù)?
本文鏈接:http://www.5511xx.com/article/coccjdj.html