如何使用paramiko查看(记录)文件传输进度?

2024-04-29 04:17:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Paramiko的SFTPClient在主机之间传输文件。我希望我的脚本打印文件传输进度类似于使用scp看到的输出。

$ scp my_file user@host

user@host password: 

my_file                          100%  816KB 815.8KB/s   00:00

$

知道吗?

提前谢谢


Tags: 文件脚本hostparamikokbmypasswordfile
1条回答
网友
1楼 · 发布于 2024-04-29 04:17:08

使用put function的可选回调参数。像这样的:

def printTotals(transferred, toBeTransferred):
    print "Transferred: {0}\tOut of: {1}".format(transferred, toBeTransferred)

sftp.put("myfile","myRemoteFile",callback=printTotals)

相关问题 更多 >