>>> 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
drwxr-sr-x 4 1176 1176 4096 Nov 17 2008 project
drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools
'226 Directory send OK.'
>>> ftp.retrbinary('RETR README', open('README', 'wb').write)
'226 Transfer complete.'
>>> ftp.quit()
有关ftplib模块的更多信息:
This module defines the class FTP and a few related items. The FTP
class implements the client side of the FTP protocol. You can use this
to write Python programs that perform a variety of automated FTP jobs,
such as mirroring other ftp servers. It is also used by the module
urllib to handle URLs that use FTP. For more information on FTP (File
Transfer Protocol), see Internet RFC 959.
既然你的问题被标记为“ftp”,我想这可能会帮助你。在
看看python中的ftplib,它同时适用于python2.x和3.x
有关ftplib模块的更多信息:
在python文档中查找2.x here和{a2}的ftplib模块。在
相关问题 更多 >
编程相关推荐