更新时间:2023-02-14 21:18:52
感谢@MartinPrikryl 的回答,我终于达到了我的目的.
Thanks to the answer of @MartinPrikryl I was able to finally achieve my purpose.
pysftp.Connection 有一个属性 sftp_client 根据文档返回活动 paramiko.SFTPClient 对象.
我使用这个属性来调用 paramiko.SFTPClient.时间
pysftp.Connection has a property sftp_client which as per documentation returns the active paramiko.SFTPClient object.
I used this property to call paramiko.SFTPClient.utime
import pysftp
conn = pysftp.Connection(host = 'host', username = 'user', password = 'password')
remote_src = '/dir1/file1.csv'
remote_dest = '/dir2/archive_file1.csv'
conn.rename(remote_src, remote_dest)
# below is the line I added after renaming the file
conn.sftp_client.utime(remote_dest, None)
conn.close()