Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何设置xsi:nil=";“真的”;使用lxml_Python 3.x_Lxml - Fatal编程技术网

Python 3.x 如何设置xsi:nil=";“真的”;使用lxml

Python 3.x 如何设置xsi:nil=";“真的”;使用lxml,python-3.x,lxml,Python 3.x,Lxml,我被要求设置一些字段属性xsi:nil=“true”,我得到的是ValueError:无效的属性名称“xsi:nil” 我尝试了下一个代码: 从lxml导入etree作为ET 元素=ET.element(元素名称) 子元素=ET.SubElement(元素“子元素名称”) sub_sub_element=ET.SubElement(element_name,sub_sub_element_name,{'xsi:nil':“true”}) 您可以使用 sub_sub_element = ET.Su

我被要求设置一些字段属性xsi:nil=“true”,我得到的是ValueError:无效的属性名称“xsi:nil”

我尝试了下一个代码:

从lxml导入etree作为ET
元素=ET.element(元素名称)
子元素=ET.SubElement(元素“子元素名称”)
sub_sub_element=ET.SubElement(element_name,sub_sub_element_name,{'xsi:nil':“true”})
您可以使用

sub_sub_element = ET.SubElement(element_name, sub_sub_element_name,  { "{http://www.w3.org/2001/XMLSchema-instance}nil" : "true" } )