首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

[ftplib]quit后login报错有关问题

2012-02-15 
[ftplib]quit后login报错问题Python codeIDLE 2.6.4 from ftplib import FTP host 192.168.1.4

[ftplib]quit后login报错问题

Python code
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就报错

[解决办法]
另起个实例吧,文档有说明:

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).

热点排行