python连接远程ftp服务器并列出目录下文件的方法

yipeiwu_com6年前服务器

本文实例讲述了python连接远程ftp服务器并列出目录下文件的方法。分享给大家供大家参考。具体如下:

这段python代码用到了pysftp模块,使用sftp协议,对数据进行加密传输

import pysftp
srv = pysftp.Connection(host="your_FTP_server", 
username="your_username",password="your_password")
# Get the directory and file listing
data = srv.listdir()
# Closes the connection
srv.close()
# Prints out the directories and files, line by line
for i in data:
  print i

希望本文所述对大家的Python程序设计有所帮助。

相关文章

python实现获取客户机上指定文件并传输到服务器的方法

本文实例讲述了python实现获取客户机上指定文件并传输到服务器的方法。分享给大家供大家参考。具体分析如下: 该程序实现了,把目标机器的某个目录(可控)的所有的某种类型文件(可控)全部获...

php模拟服务器实现autoindex效果的方法

php模拟服务器实现autoindex效果的方法

本文实例讲述了php模拟服务器实现autoindex效果的方法。分享给大家供大家参考。具体实现方法如下: 1.PHP代码如下: 复制代码 代码如下:<?php //文件浏...

python使用socket连接远程服务器的方法

本文实例讲述了python使用socket连接远程服务器的方法。分享给大家供大家参考。具体如下: import socket print "Creating socket...",...

Python实现简单的HttpServer服务器示例

要写一个类似tomcat的简易服务器,首先需弄清楚这几点: 1. 客户端(Client)和服务端(Server)的角色及作用 角色A向角色B请求数据,这时可以把A视为客户端,B视为服务端...

利用Python中SocketServer 实现客户端与服务器间非阻塞通信

利用SocketServer模块来实现网络客户端与服务器并发连接非阻塞通信。 首先,先了解下SocketServer模块中可供使用的类: BaseServer:包含服务器的核心功能与混合...