【发布时间】:2016-08-19 23:23:36
【问题描述】:
我在 python 2.7 中有这段代码
from lxml import etree
def file_dialog(self):
global root1
fd = QtGui.QFileDialog(self)
self.f1 = fd.getOpenFileName()
tree1 = etree.parse(self.f1)
当我执行这个我得到这个错误 tree1 = etree.parse(self.f1) 文件“lxml.etree.pyx”,第 3310 行,在 lxml.etree.parse (src\lxml\lxml.etree.c:72517) 文件“parser.pxi”,第 1814 行,在 lxml.etree._parseDocument (src\lxml\lxml.etree.c:106226) TypeError: 无法从 'QString' 解析
这只发生在 python 2.7 上,相同的代码适用于 python 3.4
【问题讨论】:
标签: python-2.7 python-3.x lxml