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程序设计有所帮助。

相关文章

高性能web服务器框架Tornado简单实现restful接口及开发实例

高性能web服务器框架Tornado简单实现restful接口及开发实例

有个朋友让我搞搞tornado框架,说实话,这个框架我用的不多。。。 我就把自己的一些个运维研发相关的例子,分享给大家。 怎么安装tornado,我想大家都懂。 pip inst...

使用C语言来扩展Python程序和Zope服务器的教程

有几个原因使您可能想用 C 扩展 Zope。最可能的是您有一个已能帮您做些事的现成的 C 库,但是您对把它转换成 Python 却不感兴趣。此外,由于 Python 是解释性语言,所以任...

利用django+wechat-python-sdk 创建微信服务器接入的方法

利用django+wechat-python-sdk 创建微信服务器接入的方法

1、版本说明 :python 2.7.10, Django (1.6.11.6),centos7 2、步骤说明: A、django 建立项目 django-admin.py star...

配置支持SSI

设置 SSI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...

Python基于scrapy采集数据时使用代理服务器的方法

本文实例讲述了Python基于scrapy采集数据时使用代理服务器的方法。分享给大家供大家参考。具体如下: # To authenticate the proxy, #you mu...