python - 使用 weasyprint 将 Pandas Dataframe 写入 PDF 时出现编码错误?
问题描述
我正在使用WeasyPrint生成 PDF 文件,方法的输入 HTMLwrite_pdf
由Pandas 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 对象包含除英语之外的阿拉伯语数据。
解决方案
推荐阅读
- apache-spark - 如何在 Spark 中执行简单的 t 检验?
- python - Django:将列表添加到 QuerySet
- angular - Angular 5 混合阻止内容
- spring-integration - Amazon SNS 和 Spring 集成是否相同?
- wpf - WPF 将窗口对齐到屏幕的左边缘留下间隙
- vim - 什么是vim命令复制粘贴一行'n'没有。行中的数字连续增加的次数?
- functional-programming - 从 Javascript 代码中删除 ifs
- python - python要求:如何获得相同的版本?
- java - 相机崩溃
- swift - uitableview部分折叠时单元格中的按钮不隐藏