【发布时间】:2018-09-07 06:37:38
【问题描述】:
我正在使用以下代码下载文件,
def download_dir(remote_dir, local_dir):
import os
os.path.exists(local_dir) or os.makedirs(local_dir)
dir_items = sftp.listdir_attr(remote_dir)
for item in dir_items:
# assuming the local system is Windows and the remote system is
# os.path.join won't help here, so construct remote_path manually
remote_path = remote_dir + '/' + item.filename
local_path = os.path.join(local_dir, item.filename)
if S_ISDIR(item.st_mode):
download_dir(remote_path, local_path)
else:
sftp.get(remote_path, local_path)
download_dir("/home","C:\\Users\\ShareM\\Desktop")
如何使用 DateStamp 将其下载到文件夹中?例如,如果我今天下载,它下载到的文件夹应该命名为 07/09/2018。
【问题讨论】: