最近在node中传入路径(eg: c:\usr\file)调用python,但python不识别反斜杠(\),因为会当作转义进行处理,而node中在window下识别(\),并且_dirname中也是(\),为了让python运行,所以进行替换。
let input="c:\user\myfile\file"
let forward=input.replace(/\\/g,'\')//"c:\user\myfile\file"
input=forward.replace(/\/g,'/')//"c:/user/myfile/file"