I've Element of etree having some attributes - how can we delete the attribute of perticular etree Element.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- Illegal to have multiple roots (start tag in epilo
- How to get the background from multiple images by
- Evil ctypes hack in python
The
.attrib
member of the element object contains the dict of attributes - you can use.pop("key")
ordel
like you would on any other dict to remove a key-val pair.Example :
Take care sometimes you dont have the attribute:
It is always suggested that we handle exceptions.
You do not need to
try/except
while you are popping a key which is unavailable. Here is how you can do this.Code