Jak zmienić kolejność atrybutów elementu za pomocą pięknej zupy
from simplified_scrapy.simplified_doc import SimplifiedDoc
html ='''
<word form="συ" head="2610" id="2357" lemma="συ" postag="p-s----n-" relation="ExD_AP"/>
'''
def toString(ele):
order = ['id','head','postag','from','lemma','relation']
result = '<'+ele.tag
for p in order:
result+=' {}="{}"'.format(p,ele[p])
return result+'/>'
doc = SimplifiedDoc(html)
ele = doc.word
print (toString(ele))
Glorious Gnu