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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

songguo   2021-03-21 我要评论
想了解python连接远程ftp服务器并列出目录下文件的方法的相关内容吗,songguo在本文为您仔细讲解python连接远程ftp服务器并列出目录下文件的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:python,连接远程,ftp服务器,列出目录文件,下面大家一起来学习吧。

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们