在用python的ftplib模块创建带有中文的目录时报错 Fcli = FTP () Fcli.connect ( ftphost , ftpport ) Fcli.login ( ftpuser , ftppasswd ) Fcli.mkd ( "%s/%s" % ( dir , fd_version )) 报错看出跟路径名是中文有关 解决参考
在用python的ftplib模块创建带有中文的目录时报错
Fcli = FTP()Fcli.connect(ftphost, ftpport)
Fcli.login(ftpuser, ftppasswd)
Fcli.mkd("%s/%s" % (dir, fd_version))
报错看出跟路径名是中文有关
解决参考:
https://stackoverflow.com/questions/34902486/error-for-ftplib-cwd-unicodeencodeerror-latin-1-codec-cant-encode-character
在连接ftp时,设置encoding为UTF-8
Fcli = FTP()Fcli.encoding = "UTF-8"
Fcli.connect(ftphost, ftpport)
Fcli.login(ftpuser, ftppasswd)
Fcli.mkd("%s/%s" % (dir, fd_version))