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

python连接远程ftp服务器以及列出目录下文件的方法,第1张

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

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

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

1

2

3

4

5

6

7

8

9

10

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/1344948.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-13
下一篇 2022-06-13

发表评论

登录后才能评论

评论列表(0条)

保存