在尝试修复PML(Palm Markup Language)文件时,我的测试文件似乎有非ASCII字符,这导致MakeBook出现问题。解决方法是在PML中剥离所有的非ASCII字符。
因此,在Python中尝试修复这个问题,我已经:
import unicodedata, fileinput
for line in fileinput.input():
print unicodedata.normalize('NFKD', line).encode('ascii','ignore')
然而,这会导致一个错误,即行必须是“unicode”,而不是“str”。下面是一个文件片段。
\B1a\B \tintense, disordered and often destructive rage†.†.†.\t
我不太确定在这一点上如何正确传递要处理的行。