我想通过 FTP 将文本字符串作为文件上传。
import ftplib
from io import StringIO
file = StringIO()
file.write("aaa")
file.seek(0)
with ftplib.FTP() as ftp:
ftp.connect("192.168.1.104", 2121)
ftp.login("ftp", "ftp123")
ftp.storbinary("STOR 123.txt", file)
此代码返回错误:
TypeError: 'str' does not support the buffer interface