iis - 尝试在 IIS 上运行第一个 python 脚本时出错

标签 iis python-3.x

我遵循了如何为 IIS 设置 Python 中的步骤:
Python on IIS: how?

但是当我编写脚本并尝试运行它时,它在第一行失败。我收到此错误消息:

HTTP Error 502.2 - Bad Gateway The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are " File "C:\Development\Python\helloworld.py", line 1 print 'Content-Type: text/plain' ^ SyntaxError: invalid syntax ".



这是我对 python 的第一次尝试。出了什么问题?

最佳答案

所以你的例子 helloworld.py需要改为:

print('Content-Type: text/plain')
print('')
print('Hello, world!')

Python 3 将打印更改为使用函数调用语法(可在 Python 2 中使用)。

关于iis - 尝试在 IIS 上运行第一个 python 脚本时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14207717/

相关文章:

visual-studio - HTTP 错误 403.14 - 禁止在一个 URL 上使用

iis - 使用 IISWASOnlyAesProvider 生成加密的 IIS 应用程序池标识密码

tomcat - ColdFusion 10 + IIS : Non-existant URLs that are CFM files. 执行 404 页面后检索原始 URL

python - 如何将非 ASCII 字符编码的文件重命名为 ASCII

python - 以数据帧格式打印列表

python - 有人可以解释一下如何在 python 上为 selenium 编写 xpath 吗?

iis - ServiceStack.Redis 在 Windows 服务器的 IIS 上部署时无法连接 : sPort: 0,

asp.net - 具有超过 1 个参数的 IIS 重定向

python - 尝试在 Python 3 中将时间转换为整数

Python3 的 super 和 comprehensions -> TypeError?