簡體   English   中英

多行字符串使 python cgi 腳本進入下載

[英]Multiline String makes python cgi script into download

我目前正在學習 Apache 網絡服務器上的 cgi 腳本。 我遇到了一個奇怪的問題,當我單獨打印 html 文件的每一行時,它會工作,但如果我使用多行字符串,它就會被下載。

#!/usr/bin/python3.9

website = f"""
Content-Type: text/html\n\n
<p>hello</p>
"""

print(website)

對比

#!/usr/bin/python3.9

print("Content-Type: text/html\n\n")
print("<p>hello</p>")

我能夠通過在內容類型之前沒有新行來修復它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM