Regex 如何在dirsync python模块中包含选项?
我有python版本3.7.1 我想将源目录中扩展名为.835的文件同步到目标目录。为什么这段代码会覆盖所有文件Regex 如何在dirsync python模块中包含选项?,regex,python-3.x,Regex,Python 3.x,我有python版本3.7.1 我想将源目录中扩展名为.835的文件同步到目标目录。为什么这段代码会覆盖所有文件 import dirsync dirsync.sync(source,destination,'sync',verbose=True,only='.*\.835$') 我也尝试过这样的--include选项和模式: import dirsync pattern = r'.*\.835$' dirsync.sync(source,destination,'sync',verbose=
import dirsync
dirsync.sync(source,destination,'sync',verbose=True,only='.*\.835$')
我也尝试过这样的--include选项和模式:
import dirsync
pattern = r'.*\.835$'
dirsync.sync(source,destination,'sync',verbose=True,include=pattern)
我如何解决这个问题 尝试在正则表达式后添加逗号:
import dirsync
pattern = r'.*\.835$',
dirsync.sync(source, destination, 'sync', verbose=True, include=pattern)
或:
如果您仍然存在问题,dirsync示例脚本应该为您指明正确的方向:
我还想确保你知道各种选项的作用。根据用例,“仅”可能比“包括”更有用
您可以在此处找到文档:
--仅,-o模式
要包括的正则表达式模式(每隔一个排除)
--排除-e模式
要排除的正则表达式模式
--包括-i模式
要包含的正则表达式模式(优先于排除)您的模式没有问题。这个问题一定与dirsync有关
import dirsync
dirsync.sync(source, destination, 'sync', verbose=True, include=(r'^.*\.wav$',))