[ftplib]quit后login报错问题

marvin0920 2010-02-04 02:48:51

IDLE 2.6.4
>>> from ftplib import FTP
>>> host = '192.168.1.4'
>>> port = '21'
>>> f = FTP()
>>> f.connect(host,port)
'220 Serv-U FTP Server v6.0 for WinSock ready...'
>>> f.login('admin','admin123')
'230 User logged in, proceed.'
>>> f.quit()
'221 Goodbye!'
>>> f.login('admin','admin123')

Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
f.login('admin','admin123')
File "D:\Python2.6\lib\ftplib.py", line 372, in login
resp = self.sendcmd('USER ' + user)
File "D:\Python2.6\lib\ftplib.py", line 242, in sendcmd
self.putcmd(cmd)
File "D:\Python2.6\lib\ftplib.py", line 177, in putcmd
self.putline(line)
File "D:\Python2.6\lib\ftplib.py", line 172, in putline
self.sock.sendall(line)
AttributeError: 'NoneType' object has no attribute 'sendall'
>>> f
<ftplib.FTP instance at 0x011F0B20>

一旦quit()/close()后,再login就报错
...全文
279 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
angel_su 2010-02-04
  • 打赏
  • 举报
回复
另起个实例吧,文档有说明:

FTP.close()¶
Close the connection unilaterally. This should not be applied to an already closed connection such as after a successful call to quit(). After this call the FTP instance should not be used any more (after a call to close() or quit() you cannot reopen the connection by issuing another login() method).

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧