我想知道如何将下载文件保存到其他目录。我使用下面的代码从成员这里建议测试。我尝试通过已定义的localpath尝试执行,但出现错误。
代码
COL_B IS NULL
执行上面的代码时出错。它是应保存LatestFile的目录。
with pysftp.Connection(host=myHostname, username=myUsername, password=myPassword, cnopts=cnopts) as sftp:
with sftp.cd('/home/operation/genfiles'):
files = []
localpath = '/home/mylocalDir'
for filename in sftp.listdir():
if fnmatch.fnmatch(filename, "filegen_*.json"):
files.append(filename)
latestFile = max(listFile)
sftp.get(latestFile, localpath)
请提供帮助并感谢您的指教。谢谢