第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

用Python怎么把如下文件中的中文詞條提取出來,并把這些中文做成json文件?

用Python怎么把如下文件中的中文詞條提取出來,并把這些中文做成json文件?

收到一只叮咚 2019-03-18 17:18:50
-------------------------------------------------------------------------------File:D:\svn\aCenter\windows\dap\store\vdidc\web\vue-ui\src\components\datetime_range.vuecontent:? ? ? ? ? ? ? ? 'default': '至'Line: 24Time: 2018-03-26 08:46:13-------------------------------------------------------------------------------File:D:\svn\aCenter\windows\dap\store\vdidc\web\vue-ui\src\components\piece.vuecontent:? ? ? ? ? ? ? ? <div><span class="branch-num">{{checkBranchNum}}</span><lang>個(gè)</lang><Line: 6Time: 2018-03-26 08:46:13-------------------------------------------------------------------------------File:D:\svn\aCenter\windows\dap\store\vdidc\web\vue-ui\src\components\piece.vuecontent:? ? ? ? ? ? ? ? <div class="branch"><lang>分支</lang></div>Line: 7Time: 2018-03-26 0........比如文本中的,“至”,“個(gè)”,“分支”,做成json:{“至”:“至”,“個(gè)”:“個(gè)”,“分支”:“分支”},各位有什么騷代碼都甩出來把。。。
查看完整描述

2 回答

?
絕地?zé)o雙

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊

import re


s = '''File:D:\svn\aCenter\windows\dap\store\vdidc\web\vue-ui\src\components\datetime_range.vue

content:                'default': '至'

Line: 24

Time: 2018-03-26 08:46:13


-------------------------------------------------------------------------------

File:D:\svn\aCenter\windows\dap\store\vdidc\web\vue-ui\src\components\piece.vue

content:                <div><span class="branch-num">{{checkBranchNum}}</span><lang>個(gè)</lang><

Line: 6

Time: 2018-03-26 08:46:13


-------------------------------------------------------------------------------

File:D:\svn\aCenter\windows\dap\store\vdidc\web\vue-ui\src\components\piece.vue

content:                <div class="branch"><lang>分支</lang></div>

Line: 7

Time: 2018-03-26 0'''



p2 = re.compile(r'[^\u4e00-\u9fa5]')

result = {i: i for i in " ".join(p2.split(s)).strip().split()}


# {'個(gè)': '個(gè)', '至': '至', '分支': '分支'}

優(yōu)雅的寫在本地,比如你的文件是1.txt


import re

p2 = re.compile(r'[^\u4e00-\u9fa5]')

with open('1.txt', 'r') as r:

    result = {i: i for i in ' '.join(p2.split(''.join(r.readlines()))).strip().split()}


print(result) # {'個(gè)': '個(gè)', '分支': '分支', '至': '至'}


查看完整回答
反對 回復(fù) 2019-03-23
?
紫衣仙女

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個(gè)贊

用規(guī)制式啊,字符編碼在中文范圍內(nèi)的。
這個(gè)關(guān)鍵是提取,用go語言好像比較方便,因?yàn)槠鋬?nèi)的規(guī)制式有中文標(biāo)簽 go處理中文

查看完整回答
反對 回復(fù) 2019-03-23
  • 2 回答
  • 0 關(guān)注
  • 711 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號