当前位置: 移动技术网 > IT编程>脚本编程>Python > python 从远程服务器下载东西的代码

python 从远程服务器下载东西的代码

2019年04月04日  | 移动技术网IT编程  | 我要评论

勾魂幼兽,书楼网,刘雨欣爆乳

复制代码 代码如下:

# _*_ coding:utf-8 _*_
# name gefile.py
import os
import stat
import socket
import paramiko
files=["filenamea","filenameb","filenamec","filenamed","filenamee"]
username="root"
password="123456"
host="192.168.1.66"
port=22
remotefile="/root/filename"
localpath=r'd:\docs\filename_download'
sock = socket.socket(socket.af_inet, socket.sock_stream)
sock.connect((host,port))
t = paramiko.transport(sock)
t.start_client()
t.auth_password(username,password)
sftptest=paramiko.sftpclient.from_transport(t)
sftptest.get(remotefile,localpath)
sftptest.close()
t.close()
sock.close()

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网