Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.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 通过XML文件标记读取数据并在输出到outlook时插入换行符_Python - Fatal编程技术网

Python 通过XML文件标记读取数据并在输出到outlook时插入换行符

Python 通过XML文件标记读取数据并在输出到outlook时插入换行符,python,Python,我使用下面提到的python代码读取XML文件中的以下数据,然后将其写入outlook,当它写入outlook时,我看到所有数据都打印在一行中。我想一行接一行地打印,我尝试在XML文件的每行末尾使用“br”标记,将每行环绕在“br”和“/br”周围但似乎什么都不管用,有什么建议吗? XML 输出 Release notes: 1.)Please move to this build for all further test and development activities 2.)Please

我使用下面提到的python代码读取XML文件中的以下数据,然后将其写入outlook,当它写入outlook时,我看到所有数据都打印在一行中。我想一行接一行地打印,我尝试在XML文件的每行末尾使用“br”标记,将每行环绕在“br”和“/br”周围但似乎什么都不管用,有什么建议吗? XML

输出

Release notes: 1.)Please move to this build for all further test and development activities 2.)Please use this as a basebuild to verify compilation and sanity 3.)Any CL that nees to be integrated must have a CL

我不使用标准的XML Python库,但是哪个更强大(支持XPath等)。看起来它基本上按照您的意愿工作:

>>> s = """<rel_notes>
    1.)Please move to this build for all further test and development 
    activities .
    2.)Please use this as a basebuild to verify 
    compilation and sanity
    3.)Any CL that nees to be integrated must 
    have a CL
</rel_notes>"""
>>> from lxml import etree
>>> root = etree.fromstring(s)
>>> root.text
'\n    1.)Please move to this build for all further test and development \n    activities .\n    2.)Please use this as a basebuild to verify \n    compilation and sanity\n    3.)Any CL that nees to be integrated must \n    have a CL\n'
>>> print root.text

    1.)Please move to this build for all further test and development 
    activities .
    2.)Please use this as a basebuild to verify 
    compilation and sanity
    3.)Any CL that nees to be integrated must 
    have a CL

>>> 
>s=“”
1.)请转到此版本进行所有进一步的测试和开发
活动。
2.)请将其用作基本构建来验证
编辑与健全
3.)任何需要集成的CL必须
有一个CL
"""
>>>从lxml导入etree
>>>root=etree.fromstring
>>>root.text
'\n 1.)请移动到此生成以进行所有进一步的测试和开发活动。\n 2.)请将此作为基本生成来验证编译和健全性\n 3.)任何需要集成的CL必须\n具有CL\n'
>>>打印root.text
1.)请转到此版本进行所有进一步的测试和开发
活动。
2.)请将其用作基本构建来验证
编辑与健全
3.)任何需要集成的CL必须
有一个CL
>>> 
Release notes: 1.)Please move to this build for all further test and development activities 2.)Please use this as a basebuild to verify compilation and sanity 3.)Any CL that nees to be integrated must have a CL
>>> s = """<rel_notes>
    1.)Please move to this build for all further test and development 
    activities .
    2.)Please use this as a basebuild to verify 
    compilation and sanity
    3.)Any CL that nees to be integrated must 
    have a CL
</rel_notes>"""
>>> from lxml import etree
>>> root = etree.fromstring(s)
>>> root.text
'\n    1.)Please move to this build for all further test and development \n    activities .\n    2.)Please use this as a basebuild to verify \n    compilation and sanity\n    3.)Any CL that nees to be integrated must \n    have a CL\n'
>>> print root.text

    1.)Please move to this build for all further test and development 
    activities .
    2.)Please use this as a basebuild to verify 
    compilation and sanity
    3.)Any CL that nees to be integrated must 
    have a CL

>>>