gpt4 book ai didi

python - 标题之前的脚本输出结束

转载 作者:太空宇宙 更新时间:2023-11-03 16:39:19 25 4
gpt4 key购买 nike

当我在 Windows 上的编辑器(我尝试过 Netbeans、PyCharm 和 Notepad++)中创建文件 test.py(请参阅下面的代码)并将其上传到服务器 (Ubuntu) 时,我收到此错误:

标题之前的脚本输出结束:test.py

但是当我使用 vi 命令行编辑器直接在服务器上创建文件时,页面显示没有任何错误。知道如何解决这个问题吗?

这是 test.py 的代码

#!/usr/bin/python

# send content type
print("Content-Type: text/html\n\n")

print("Good")

最佳答案

我认为这是因为 Windows 回车符。

这是两个字符:

\r is carriage return;
\n is line feed.

两个字符组合起来代表 Windows 上的新行。而在 Linux 上,\n 代表新行。

Notepad++ 有一个选项可以指定您要使用的格式:

转到设置 --> 首选项并选择 linux:

enter image description here

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

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