我有一个 txt 文件,其中包含一个带刻度的列表
Done List
☑ grocery
☑ electronics
上面的列表是使用 Python 创建的,如下所示:
chkbx = u"\u2611" #u'\U0001F5F9'
for ...
with open('List.txt','a',encoding='utf-8') as f:
f.write(f"{chkbx} {activity}\n")
我想使用FPDF
python 库将 txt 文件转换为 PDF。我使用以下命令保存
pdf.output('list.pdf').encode('utf-8')
并得到以下错误:
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2611' in position 516: ordinal not in range(256)
根据https://pyfpdf.readthedocs.io/en/latest/Unicode/index.html它应该可以工作(?)我在这里错过了什么?