List files with UTF-8 characters in the name in Python ftplib

后端 未结 1 1853
执笔经年
执笔经年 2021-01-16 11:35

I need to mirror files from an FTP server to a local machine, but some files/directories have special characters on it, e.g:

print(ftp.nlst())
>>{\'Mar         


        
相关标签:
1条回答
  • 2021-01-16 12:00

    Assuming the filenames are in UTF-8 encoding, in Python 3, this should do:

    ftp.encoding = "UTF-8"
    print(ftp.nlst())
    
    0 讨论(0)
提交回复
热议问题