Here is a function using a triple quoted f-string with lots of sub-elements:
def pass_empty_string(param):
from lxml import etree
xml = etree.XML(f'''
<root>
<child>text</child>
<child>{param}</child>
...
</root>''')
return xml
Is it possible to get an empty </child>
element when param
is getting None
or ''
value?