为了避免写一打长而丑陋的三元,比如p_count = root.pool_count if hasattr(root, 'pool_count') else (-1),我编写了GetThis(el,attr如何使函数将el & attr的值连接到元素中,而不是将attr作为文字连接?", line 10, in GetThis File "lxml.objectify.pyx", line 2
像这样使用lxml.objectify:
o = objectify.fromstring("<a><b atr='someatr'>oldtext它似乎是直接用新创建的元素替换元素,而不是简单地替换元素的文本。有没有一种方法可以在objectify中做到这一点,而不必将其拆分成不同的元素并涉及etree?我