本人刚接触python3,尝试写了一个ftp下载文件的脚本
下载是从虚拟机上linux系统里下载一个文件,但是总是在接收数据那一行报错,代码如下:fromftplibimportFTPserverip='192.168.220.1...
下载是从虚拟机上linux系统里下载一个文件,但是总是在接收数据那一行报错,代码如下:
from ftplib import FTP
serverip='192.168.220.128'
port = 21
Login_name='linux'
Login_password = '**********'
FTP_DIR = '/home/linux/'
STORE_DIR = 'E:/work_space/python_prj/'
ftp = FTP()
ftp.connect(serverip, port)
ftp.login(Login_name, Login_password)
print(ftp.getwelcome())
ftp.cwd(FTP_DIR)
file_list = ftp.nlst()
for each_file in file_list:
print(each_file)
file_name = 'my_strlwr.c'
#print(file_name)
store_name = STORE_DIR + file_name
#print(store_name)
#print('come here')
try:
ftp.retrbinary('RETR' + file_name, open(store_name, 'wb').write)
except Exception as e:
print("receiving bin data error %s"%e)
ftp.quit()
运行总是打印receiving bin data error 500 Unknown command.
请大神帮我看一下是什么地方错了。万分感谢。 展开
from ftplib import FTP
serverip='192.168.220.128'
port = 21
Login_name='linux'
Login_password = '**********'
FTP_DIR = '/home/linux/'
STORE_DIR = 'E:/work_space/python_prj/'
ftp = FTP()
ftp.connect(serverip, port)
ftp.login(Login_name, Login_password)
print(ftp.getwelcome())
ftp.cwd(FTP_DIR)
file_list = ftp.nlst()
for each_file in file_list:
print(each_file)
file_name = 'my_strlwr.c'
#print(file_name)
store_name = STORE_DIR + file_name
#print(store_name)
#print('come here')
try:
ftp.retrbinary('RETR' + file_name, open(store_name, 'wb').write)
except Exception as e:
print("receiving bin data error %s"%e)
ftp.quit()
运行总是打印receiving bin data error 500 Unknown command.
请大神帮我看一下是什么地方错了。万分感谢。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询