'latin-1' codec can't encode characters in position 6-7: ordinal not in range(256)

我遇到在这个错误,是用python ftplib上传文件 出现的报错,网上找了很多解决不了我的问题,仔细看一下报错信息,latin,这种编码格式,识别不了

解决办法:

进到ftplib.py 源码,

    debugging = 0
    host = ''
    port = FTP_PORT
    maxline = MAXLINE
    sock = None
    file = None
    welcome = None
    passiveserver = 1
    encoding = "latin-1"

找到这一段,把encoding 改一下, encoding= “utf-8”,完美解决我的问题,希望能帮到你们 

你可能感兴趣的:(python,ftplib,FTP,python)