Python 如何使reportlab pdf生成器忽略<;或>;象征

Python 如何使reportlab pdf生成器忽略<;或>;象征,python,pdf,reportlab,Python,Pdf,Reportlab,我正在尝试使用reportlab组合一个pdf文档。当我试图用符号写出一行时,文本就会消失,因为reportlab的段落支持xml标记。如何禁用此行为?我的很多文章都是包含符号的math forumlas,这里是我正在谈论的一个例子 from reportlab.platypus import SimpleDocTemplate, Paragraph from reportlab.lib.styles import getSampleStyleSheet styles = getSampleS

我正在尝试使用reportlab组合一个pdf文档。当我试图用符号写出一行时,文本就会消失,因为reportlab的段落支持xml标记。如何禁用此行为?我的很多文章都是包含<或>符号的math forumlas,这里是我正在谈论的一个例子

from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.lib.styles import getSampleStyleSheet

styles = getSampleStyleSheet()

def page_one(canvas, doc):
    canvas.saveState()
    canvas.setFont('Helvetica',12)
    canvas.restoreState()

def main():
    doc = SimpleDocTemplate("example.pdf")
    Story = list()
    style = styles["Normal"]
    example_disappear = u'this is visible <this text is not visible> this is visible'
    p = Paragraph(example_disappear, style)
    Story.append(p)
    doc.build(Story, onFirstPage=page_one)

if __name__ == "__main__":
    main()
并将我的段落修改为

p = Paragraph(escape(example_disappear), style)

并且文本可见。

尝试使用
代替。谢谢您的回答。我试了你的建议,得到了。。此可见<此文本不可见>此可见。就在半路上。
p = Paragraph(escape(example_disappear), style)