问题描述
im正在尝试解析docx文件。我先将其解压缩,然后尝试使用with open(..)
读取Document.xml文件,并引发错误:“'charmap'编解码器无法解码位置7618的字节0x98:字符映射为”。 XML是“ UTF-8”编码:
错误:
我编写了以下代码:
with open(self.tempDir + self.CONfig['main_xml']) as xml_file:
self.dom_xml = etree.parse(xml_file)
我想强制编码为UTF-8,但后来我无法正确阅读etree.fromstring(..)
7618符号(来自错误)是:
请帮助我。如何正确读取xml文件? 谢谢
解决方法
此方法在您的file上没有错误:
import tensorflow as tf
@tf.function
def f(x,y):
return x ** 2 + y
x = tf.constant([2,3])
y = tf.constant([3,-2])
f(x,y)