python3从零学习-5.10.9、ftplib—FTP 协议客户端
源代码: Lib/ftplib.py
这个模块定义类FTP和一些相关项。FTP类实现FTP协议的客户端。您可以使用它编写Python程序来执行各种自动FTP作业,比如镜像其他FTP服务器。模块urllib也使用它。请求处理使用FTP的url。有关FTP(文件传输协议)的更多信息,请参见Internet RFC 959。
下面是一个使用ftplib模块的示例会话:
>>> from ftplib import FTP
>>> ftp = FTP('ftp.debian.org') # connect to host, default port
>>> ftp.login() # user anonymous, passwd anonymous@
'230 Login successful.'
>>> ftp.cwd('debian') # change into "debian" directory
>>> ftp.retrlines('LIST') # list directory contents
-rw-rw-r-- 1 1176 1176 1063 Jun 15 10:18 README
drwxr-sr-x 5 1176 1176 4096 Dec 19 2000 pool