[英]I want to extract specific text from txt or json file
我想從一堆文本中提取特定的行。 有沒有辦法從這個文件中提取所有以“text”開頭並以“}”結尾的行? 這只是我擁有完整文件的一段代碼..
"edge_media_to_caption": {
"edges": [
{
"node": {
"text": **"Summer is a state of mind.\n\n#locobeachresort #locoland #beachlife #batroun"**
}
}
]
},
"edge_media_to_caption": {
"edges": [
{
"node": {
"text": **"Sunshine is the best medicine.\n\n#locobeachresort #locoland #beachlife #batroun"**
}
}
]
},
如果您對 python 感興趣,那么
lines = <your json>
for line in lines.split('\n'):
if 'text' in line:
<do whatever you want with the line>
選擇這些行
"text": **"Summer is a state of mind.
"text": **"Sunshine is the best medicine.
沒有從文件中過濾特定行的方法。 您必須在 memory 中加載文本,除非您對文件結構有過早的了解
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.