我试图实现FTP服务器和客户机来传输文件,但基本上无法使用python中的ftplib
模块在这两者之间建立连接。。。。在
这就是我所做的,我如何修复代码? 还有别的办法吗?在
我的服务器的代码:-
#making the important imports for file transfer :
from ftplib import FTP
ftp_object_server=FTP()
#s = socket.socket()
host = "121.0.0.1"
port = 1227
ftp_object_server.connect(host,port)
while True:
c, addr = ftp_object_server.accept()
print c
print addr# Establish connection with client.
print 'Got connection from', addr
c.send('Thank you for connecting')
ftp_object_server.close() # Close the connection
我的客户代码:
^{pr2}$
来自标准库的ftplib模块仅覆盖FTP协议的客户端部分。 所以您所做的就是尝试打开到
121.0.0.1
的两个连接。我假设你指的是localhost
,反正就是127.0.0.1
。在不知道自己到底想实现什么,有一些选择:
python -m SimpleHTTPServer
(或python3中的python3 -m http.server
)和{a2}作为客户端相关问题 更多 >
编程相关推荐