标签: python
是否可以在一行列表理解中执行以下操作?
from lxml import etree valid_xml_strings = [] for xml_string in xml_strings: try: etree.fromstring(xml_string) except etree.XMLSyntaxError: continue valid_xml_strings.add(xml_string)