Python中FTP 上传出现10060错误,怎么解决?



 #!/usr/bin/python
#-*- coding: utf-8 -*-

from ftplib import FTP

def ftpconnect():
    ftp_server = 'XXXXXXX'
    port=21
    username = 'anonymous'
    password = ''
    ftp=FTP()
    ftp.set_debuglevel(2) #打开调试级别2,显示详细信息
    ftp.connect(ftp_server,port) #连接
    ftp.login(username,password) #登录,如果匿名登录则用空串代替即可
    return ftp


def uploadfile():

    remotepath = "/"
    ftp = ftpconnect()
    bufsize = 1024
    localpath = 'd:\\zh.jpg'
    fp = open(localpath,'rb')
    ftp.storbinary('STOR '+ remotepath ,fp,bufsize) #上传文件
    #ftp.set_debuglevel(0)
    fp.close() #关闭文件
    ftp.quit()
    print 'Success'


if __name__=='__main__':
     uploadfile()

请输入图片描述

python ftp 网络编程

deone 10 years, 3 months ago

1.连接类型
2.FTP服务器故障
3.端口

片翼天使小萨 answered 10 years, 3 months ago

Your Answer