我想上传一个 ASCII 文件。这曾经在 Python 2 中工作:
ftp = ftplib.FTP('ftp.domain.com')
ftp.login('domain.com',password)
ftp.cwd('subdirectory')
ftp.storlines('STOR ' + 'file.htm', open('file.htm','r'))
ftp.close()
但是,在 Python 3 中,它返回此错误:
File "/usr/local/lib/python3.3/ftplib.py", line 497, in storlines
if buf[-1] in B_CRLF: buf = buf[:-1]
TypeError: Type str doesn't support the buffer API
我究竟做错了什么?