Python3中使用dirsync同步目录时,如何传递create参数创建目标目录?
解决dirsync同步时目标目录不存在的问题
直接在sync函数调用中添加create=True参数即可,该参数对应命令行的-c/--create选项,会自动创建不存在的目标目录。修改后的代码如下:
from dirsync import sync source_name='directory2828_bkp20220524' source_path = '/home/micky/'+source_name target_path = '/mnt/backup_001/'+source_name sync(source_path, target_path, 'sync', verbose=True, create=True)
内容的提问来源于stack exchange,提问作者user22216550
相关产品推荐
相关产品推荐

