gpt4 book ai didi

Python CGI 标题错误之前脚本输出结束

转载 作者:太空宇宙 更新时间:2023-11-03 18:13:32 27 4
gpt4 key购买 nike

首先,是的,还有其他类似标题的问题,不,这不是重复的。

当我在网络服务器上使用 python 和 CGI​​ 时,我遇到了一个非常奇怪的问题。

下面给出了指示的错误

#! /python34/python
import cgi, Cookie, os
print("Content-Type: text/html\n")
print("Output")

但是,如果我不导入 Cookie,它就可以工作

#! /python34/python
import cgi, os
print("Content-Type: text/html\n")
print("Output")

对此有什么想法吗?

最佳答案

您正在学习的教程可能适用于 Python 2。在 Python 3 中,Cookie 库已重命名为 http.cookies。如果您运行 2to3 在您的代码上,它应该突出显示您需要进行的任何更改。

https://docs.python.org/2/library/cookie.html

关于Python CGI 标题错误之前脚本输出结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25421821/

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