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

yipeiwu_com5年前服务器

本文实例讲述了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程序设计有所帮助。

相关文章

php调整服务器时间的方法

本文实例讲述了php调整服务器时间的方法。分享给大家供大家参考。具体如下: 这里主要使用strftime函数实现这一功能,代码很简单,如下所示: $today = date('Y-m...

开启CURL扩展,让服务器支持PHP curl函数(远程采集)

curl()、file_get_contents()、snoopy.class.php这三个远程页面抓取或采集中用到的工具,默迹还是侵向于用snoopy.class.php,因为他效率比...

php5.2的curl-bug 服务器被php进程卡死问题排查

php5.2的curl-bug 服务器被php进程卡死问题排查

前几天东政同学反馈说Linode服务器快卡死了,今天有时间排查了一下具体原因,最终原因稍微有点悲壮:file_get_contents没有设置超时时间,加上我用的php5.2关于curl...

Python实现telnet服务器的方法

本文实例讲述了Python实现telnet服务器的方法。分享给大家供大家参考。具体实现方法如下: import threading class myThread(threading...

python定时采集摄像头图像上传ftp服务器功能实现

首先是截图,从摄像头截取一幅图像: 复制代码 代码如下:while 1:   #测试摄像头的存在    try:  ...