F.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:A-Z-of-Python 作者: crvaden 项目源码 文件源码
def ftp_connect():  # Connect to the FTP and start asking for commands
    while True:  # If connection fails, retry
        site_address = input('Enter FTP address: ')
        try:

            with ftplib.FTP(site_address) as ftp:
                ftp.login()
                print(ftp.getwelcome())
                print('Directory Listing for', ftp.pwd())
                ftp.dir()
                print('Valid commands are cd/get/exit - ex: get readme.txt')
                ftp_command(ftp)
                break  # once ftp_command() exits, end this function (exit program)
        except ftplib.all_errors as e:  # treat all exceptions at this point as a connection failure
            print('Failed to connect, check your address.', e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号