Reputation: 1
I am having trouble listing files from an FTP server using Python's ftplib
. The server appears to send data that is causing a UTF-8 decoding error. Here’s a summary of the problem and what I’ve tried:
Code
from ftplib import FTP
try:
ftp = FTP('ftp')
ftp.login(user='user', passwd='psw')
ftp.encoding = 'utf-8'
arquivos = ftp.nlst()
print(f'Arquivos: {arquivos}')
except Exception as Err:
print(f'Erro na conexão: {Err}')
finally:
if 'ftp' in locals():
ftp.quit()
The error: Error in connection: 'utf-8' codec can't decode byte 0xe3 in position 17: invalid continuation byte
Additional Information The server does not support UTF-8, as indicated by FileZilla with the message: Server does not support non-ASCII characters.
I also tried using latin-1 encoding, but it returns the same error
Upvotes: 0
Views: 50