我有以下文字:
xml = '''
<accessibility_info>
<accessibility role="captions" available="true" />
</accessibility_info>
<crew_member billing="top"
<display_name>John Viscount</display_name>
</crew_member>
<products>
<territory>GB</territory>
</products>'''
我需要删除以下<crew_member>
块。这就是我目前正在做的事情:
clean_xml = re.sub('<crew_member>.*</crew_member>', '', metadata_contents,
flags=re.DOTALL)
但是,它还添加了一个换行符:
<accessibility_info>
<accessibility role="captions" available="true" />
</accessibility_info>
<products>
<territory>GB</territory>
</products>
我将如何更改正则表达式以去除换行符,所以它看起来像:
<accessibility_info>
<accessibility role="captions" available="true" />
</accessibility_info>
<products>
<territory>GB</territory>
</products>'