首页 > 解决方案 > 为什么我不能使用 Python 连接到我的 FTP 服务器?

问题描述

为什么我无法连接到我的 FTP?当我指定一个端口时,我收到错误“socket.gaierror: [Errno -2] name of service not known”,当我没有指定我的端口时,我收到 [errno 111] Connection denied。我究竟做错了什么?

from ftplib import FTP
from pathlib import Path

file_path = ('TEST.txt')

with FTP('url:port', 'user', 'pass') as ftp, 
open(file_path, 'rb') as file:
ftp.storbinary(f'STOR {file_path.name}', file)

标签: pythonftpsftp

解决方案


推荐阅读