This question already has an answer here:
这个问题已经有了答案:
- How do I parse XML in Python? 12 answers
- 如何在Python中解析XML ?12个答案
I have this code in the xml view:
我在xml视图中有这个代码:
<field name="fueled" sum="Sum of fueled"/>
How can I get value sum attribute to do some calculating in python file?
如何让value sum属性在python文件中进行计算?
1 个解决方案
#1
0
Just do this:
只是这样做:
from lxml import etree
etree.fromstring('<field name="fueled" sum="Sum of fueled"/>').xpath('//field/@sum')[0]
#1
0
Just do this:
只是这样做:
from lxml import etree
etree.fromstring('<field name="fueled" sum="Sum of fueled"/>').xpath('//field/@sum')[0]