问题
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())
>>{'Mariana', 'Marina', 'MartÃ\xadn', 'MatÃ\xadas'}
回答1:
Assuming the filenames are in UTF-8 encoding, in Python 3, this should do:
ftp.encoding = "UTF-8"
print(ftp.nlst())
来源:https://stackoverflow.com/questions/53091871/list-files-with-utf-8-characters-in-the-name-in-python-ftplib