【发布时间】:2018-05-19 14:50:18
【问题描述】:
我有一个如下所示的 docx 文件。
[ { "name": "ravi",
"city": "chennai",
"country": "india"
}
{
"name": "raj",
"city": "chennai",
"country": "india"
}
]
我正在尝试将此内容作为字典列表来阅读。我试过了。
from docx import Document
document = Document('2255858_1321163255_worldcupdata.docx')
s=""
for i in document.paragraphs:
s+=i.text
json_list=s[1:-1].split('}')
但我无法将字符串转换为 dict,我收到以下语句的值错误。
dict('{ "name": "ravi", "city": "chennai", "country": "india" }')
ValueError: dictionary update sequence element #0 has length 1; 2 is required
【问题讨论】:
标签: python json list dictionary docx