文本打破特殊字符python

时间:2015-11-28 13:31:42

标签: python xml string

Hello Comunity我在使用python编写XML文件时遇到了麻烦。

我希望在文件中写入文字:

<!-- @(#) $Id: ./etc/rules/apache_rules.xml, 2011/09/08 dcid Exp $

  -  Official Apache rules for OSSEC.
  -
  -  Copyright (C) 2009 Trend Micro Inc.
  -  All rights reserved.
  -
  -  This program is a free software; you can redistribute it
  -  and/or modify it under the terms of the GNU General Public
  -  License (version 2) as published by the FSF - Free Software
  -  Foundation.
-->

 <rule id="30100" level="0">
    <decoded_as>apache-errorlog</decoded_as>
    <description>Apache messages grouped.</description>
  </rule>   

但是辛博尔;在评论中,打破字符串,我的文件只有

<!-- @(#) $Id: ./etc/rules/apache_rules.xml, 2011/09/08 dcid Exp $

  -  Official Apache rules for OSSEC.
  -
  -  Copyright (C) 2009 Trend Micro Inc.
  -  All rights reserved.
  -
  -  This program is a free software

没有;写所有,我可以替换那个辛博尔但另一个可以再次崩溃文本?为什么??

PS:im writig file with

f = open("/tmp/l.xml",'w')
f.write(data["contentXML"])

0 个答案:

没有答案