Franmuzzio
Franmuzzio

Reputation: 25

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

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'}

Upvotes: 1

Views: 1038

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202393

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

ftp.encoding = "UTF-8"
print(ftp.nlst())

Upvotes: 2

Related Questions