gpt4 book ai didi

python - 在python中将http响应Content-Type设置为 "xml"

转载 作者:行者123 更新时间:2023-12-01 06:06:24 32 4
gpt4 key购买 nike

如何在 html 页面上显示 xml?

如何在 python text/html 中设置?

我在 html 中写的是:

response.out.write

最佳答案

假设您使用mod_python:

response.content_type = "text/xml"

或者:

response.content_type = "text/html"

http://www.modpython.org/live/current/doc-html/pyapi-mprequest-mem.html

content_type

String. The content type. Mod_python maintains an internal flag (req._content_type_set) to keep track of whether content_type was set manually from within Python. The publisher handler uses this flag in the following way: when content_type isn't explicitly set, it attempts to guess the content type by examining the first few bytes of the output.

<小时/>

如果您只想在文本文件中获得漂亮的 xml 输出,请使用 BeautifulSoup xml 上的 prettify()

关于python - 在python中将http响应Content-Type设置为 "xml",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7801280/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com