我的 S005_179-205M-2 格式的
它應該用阿拉伯語印刷。我檢查過決議器不是用阿拉伯語讀取的。如何確保決議器使用 Unicode 進行決議?
uj5u.com熱心網友回復:
下面的代碼決議并從 xml 中提取一些資訊
import xml.etree.ElementTree as ET
xml = '''<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:base="http://example.org" xml:id="example_v1">
<teiHeader>
<fileDesc>
<titleStmt>
<title>test</title>
</titleStmt>
<publicationStmt>
<p>test</p>
</publicationStmt>
<sourceDesc>
<p>test</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text xml:lang="ar">
<body>
<div type="chapter" n="5" xml:lang="ar">
<div type="section" n="5.179">
<head type="30">
????????? ??? ????????? ???????? :
<quote type="quran" n="5:74">?????? ?????????? ????? ??????? ??????????????????? ????????? ??????? ???????</quote>
</head>
<p n="nothadith" ana="adyan kalam yes">
???? ????? ???? : ???? ???? ???? ????????
<name role="organization">????????</name>
? ?????? ?????? :
<quote type="quran" n="5:72">
????? ??????? ????
<name role="person">??????????
????? ????????</name>
</quote>
? ?????? ?????? :
<quote type="quran" n="5:73">????? ???????
??????? ????????</quote>
? ??? ???? ?? ??? ? ? ?????? ??? ???? ????? ??
?? ?????? ? ??????? ????? ??????? ??? ???? :
<quote type="quran" n="5:74">????????? ???????</quote>
? ????? ???????? ?? ???? ? ???????? ???
<pb type="turki" n="8:582" />
????? ??? ??????? ?
<quote type="quran" n="5:34">???????</quote>
??? ?? ????? ??????? ? ?????????? ??? ?? ???
??? ???? ? ????? ???? ?? ????? ??? ??? ?? ??????? ??? ??? .
</p>
</div>
</div>
</body>
</text>
</TEI>'''
root = ET.fromstring(xml)
for idx,quote in enumerate(root.findall('.//{http://www.tei-c.org/ns/1.0}quote'),1):
print(f'{idx}): {quote.text.strip()}')
輸出
1): ?????? ?????????? ????? ??????? ??????????????????? ????????? ??????? ???????
2): ????? ??????? ????
3): ????? ???????
??????? ????????
4): ????????? ???????
5): ???????
uj5u.com熱心網友回復:
您的決議器正在以 unicode 進行決議,tostring但未撰寫 unicode。
使用etree.tostring(root, encoding="unicode")或etree.tostring(root, encoding="utf-8")
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/316691.html
