import xml.etree.ElementTree as xml
xm = xml.fromstring('<element attribute="value">text<subelement subattribute="subvalue">subtext</subelement></element>')
subelement = xml.findtext("subtext")
无效。我已经尝试了很多东西:
>>> xm.
xm.__class__( xm.__copy__( xm.__deepcopy__( xm.__delattr__( xm.__delitem__( xm.__dir__( xm.__doc__ xm.__eq__( xm.__format__( xm.__ge__( xm.__getattribute__( xm.__getitem__( xm.__getstate__( xm.__gt__( xm.__hash__( xm.__init__( xm.__le__( xm.__len__( xm.__lt__( xm.__ne__( xm.__new__( xm.__reduce__( xm.__reduce_ex__( xm.__repr__( xm.__setattr__( xm.__setitem__( xm.__setstate__( xm.__sizeof__( xm.__str__( xm.__subclasshook__( xm.append( xm.clear( xm.extend( xm.find( xm.findall( xm.findtext( xm.get( xm.getchildren( xm.getiterator( xm.insert( xm.items( xm.iter( xm.iterfind( xm.itertext( xm.keys( xm.makeelement( xm.remove( xm.set(
唯一可行的是
>>> xm.getchildren()
[<Element 'subelement' at 0x0000029B288AD958>]
这似乎不是最佳方式:c