gpt4 book ai didi

python-2.7 - 使用python连接ftp服务器

转载 作者:行者123 更新时间:2023-12-03 19:21:49 25 4
gpt4 key购买 nike

我尝试使用 python 代码连接到手机中的 ftp 服务器,但出现错误。

代码

import ftplib
server = ftplib.FTP()
server.connect('192.168.135.101', 5556)
server.login('svgn','123456')
print (server.dir())

错误

C:\Python27\python.exe C:/Users/alisivgin/PycharmProjects/untitled2/deneme2.py Traceback (most recent call last): File "C:/Users/alisivgin/PycharmProjects/untitled2/deneme2.py", line 3, in server.connect('192.168.135.101', 5556) File "C:\Python27\lib\ftplib.py", line 132, in connect self.sock = socket.create_connection((self.host, self.port), self.timeout) File "C:\Python27\lib\socket.py", line 571, in create_connection raise err socket.error: [Errno 10061] Hedef makine etkin olarak reddetti�inden ba�lant� kurulamad

Process finished with exit code 1



谢谢。

最佳答案

试试下面的代码,即使我以前也遇到过同样的问题。

import ftplib
server = ftplib.FTP()
server.connect('192.168.135.101', 5556)
server.login('svgn','123456')
# You don't have to print this, because this command itself prints dir contents
server.dir()

关于python-2.7 - 使用python连接ftp服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28749534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com