lxml.etree.SerialisationError: IO_ENCODER

every blog every motto: better late than never.

0. 前言

在将xpath的element 元素,转换成html源码,报了以下错误,
在这里插入图片描述
我记得我之前是没错的,whatever,下面是解决方法

1. 正文

将下面这段代码

    byte_ = etree.tostring(temp)

变成下面这段代码

    byte_ = etree.tostring(temp,encoding='utf-8')

就能解决。 以上

参考文献

[1] https://blog.csdn.net/jiekaile/article/details/102983116

发布了52 篇原创文章 · 获赞 47 · 访问量 9408
App 阅读领勋章
微信扫码 下载APP
阅读全文

openpyxl 生产xlsx文件报错

12-24

python 3.6 openpyxl 3.0.2 ```python from openpyxl import Workbook from openpyxl.utils import get_column_letter wb = Workbook() dest_filename = 'empty_book.xlsx' ws1 = wb.active ws1.title = "range names" for row in range(1, 40): ws1.append(range(600)) ws2 = wb.create_sheet(title="Pi") ws2['F5'] = 3.14 ws3 = wb.create_sheet(title="Data") for row in range(10, 20): for col in range(27, 54): _ = ws3.cell(column=col, row=row, value="{0}".format(get_column_letter(col))) print(ws3['AA10'].value) wb.save(filename = dest_filename) ``` Traceback (most recent call last): File "C:/Users/Administrator/Desktop/python 报价单生成脚本/111.py", line 36, in <module> wb.save(filename = dest_filename) File "D:\Anaconda3\lib\site-packages\openpyxl\workbook\workbook.py", line 408, in save save_workbook(self, filename) File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 293, in save_workbook writer.save() File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 275, in save self.write_data() File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 75, in write_data self._write_worksheets() File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 215, in _write_worksheets self.write_worksheet(ws) File "D:\Anaconda3\lib\site-packages\openpyxl\writer\excel.py", line 200, in write_worksheet writer.write() File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet\_writer.py", line 354, in write self.write_top() File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet\_writer.py", line 98, in write_top self.write_properties() File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet\_writer.py", line 60, in write_properties self.xf.send(props.to_tree()) File "D:\Anaconda3\lib\site-packages\openpyxl\worksheet\_writer.py", line 294, in get_stream xf.write(el) File "src/lxml/serializer.pxi", line 1230, in lxml.etree._IncrementalFileWriter.write TypeError: got invalid input value of type <class 'xml.etree.ElementTree.Element'>, expected string or Element 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 书香水墨 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览