首页 > 解决方案 > 使用 weasyprint 将 Pandas Dataframe 写入 PDF 时出现编码错误?

问题描述

我正在使用Wea​​syPrint生成 PDF 文件,方法的输入 HTMLwrite_pdfPandas to_html方法生成,如下所示:

html = open('output.html', 'w+',)
df.to_html(html.name)
HTML(html).write_pdf('output.pdf')

但我收到以下错误:

TypeError: Cannot set an encoding with a unicode input, set ['override_encoding', 'transport_encoding']

我知道如何解决这个问题吗?

注意: Dataframe 对象包含除英语之外的阿拉伯语数据。

标签: pythonpandasweasyprint

解决方案


推荐阅读