【发布时间】:2020-05-03 13:37:47
【问题描述】:
我正在尝试使用 Python 和 ftplib 将 .txt 文件上传到 FTP 服务器。连接作品,上传作品 - 只是有点奇怪。
我的文件如下所示:
line1
line2
line3
...
它是通过简单的写入创建的
file.write('line1\n) ...
我使用 storbinary 上传它(与 storlines 相同)
ftp = ftplib.FTP() # and connecting to the server
file = open(file_name, 'rb')
ftp.storbinary('STOR file.txt', file)
现在,当我查看服务器中的文件时(也尝试下载它然后查看),它看起来像这样:
line1
line2
line3
...
为什么会这样?它必须在上传时发生,从那时起它看起来就像它的预期那样。
【问题讨论】:
-
.xml 也是如此 - 似乎没有链接到文件类型