使用xammp服务器运行python时出错

2024-09-19 23:26:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我对使用xammp服务器运行python是新手。通过以下链接Running Python scripts with Xampp,我已经完成了在xammp服务器中运行python所需的所有设置。在尝试运行代码时,我总是会出错

**Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.**

我的错误日志显示: [Tue Jan 19 10:29:34.529875 2021][cgi:error][pid 11652:tid 1860][client::1:50570]来自脚本“python.py”的格式错误的标题:错误的标题:Hello World

我也附上了我的文件的代码

#! C:\Users\"UserName"\AppData\Local\Programs\Python\Python39\python.exe
print("Content-Type: text/html\n\n")
import cgi

print("Hello Python")

我已经尽我所能寻找解决办法,但没有任何帮助。请帮我找到解决办法。多谢各位


Tags: andtheto代码服务器标题helloserver
1条回答
网友
1楼 · 发布于 2024-09-19 23:26:55

更新\n\n以使用回车符(\r\n\r\n),并在中添加另一个回车符

这将使您的HTTP头有效,因为它们可能没有正确终止

编辑:您也可以尝试多行打印说明,例如

print "Content-type: text/html"
print ""

这是将主体解释为标题(从未终止),因此正确终止主体应该可以修复它

相关问题 更多 >