我正在使用fpdf python包创建一个.pdf文件。
以下是我的代码:
import fpdf
pdf = fpdf.FPDF(format='letter') # pdf format
pdf.add_page() # create new page
pdf.set_font("Arial", size=18) # font and textsize
pdf.cell(200, 10, txt="An enhanced Interactive’ Python", ln=1, align="C")
pdf.output("test.pdf")但它给了我一个错误,因为:
UnicodeEncodeError:‘拉丁-1’编解码器不能编码字符'\u2019‘位置74:序数不在范围内(256个)
我不知道为什么这是弹出时,我想保存的pdf使用pdf.output("test.pdf")。
发布于 2022-01-06 07:08:02
U+2019是一个花哨的右单引号,在单词"Interactive“之后的字符串中有。我想你根本不想要那个角色。
https://stackoverflow.com/questions/70603563
复制相似问题