openpyxl无法处理编写lxml.etree._ElementUnicodeResult

时间:2019-11-21 16:46:00

标签: lxml openpyxl

此脚本仅用于演示目的,通常在解析某些数据时会给出lxml.etree._ElementUnicodeResult类型。由于某种原因,无法使用openpyxl将这种类型的字符串写入Excel。这种字符串是某种错误还是预期的行为?

from openpyxl import Workbook
import lxml

string_to_write = lxml.etree._ElementUnicodeResult("just a string")

outfile = Workbook()
ws = outfile["Sheet"]

ws.cell(row=1, column=1).value = "just a string"
ws.cell(row=1, column=2).value = string_to_write

outfile.save("output.xlsx")

0 个答案:

没有答案