Python Convert Back Slashes to forward slashes

前端 未结 6 1913
滥情空心
滥情空心 2020-12-15 16:11

I am working in python and I need to convert this:

C:\\folderA\\folderB to C:/folderA/folderB

I have three approaches:

dir = s.replace(\'\\\\         


        
6条回答
  •  情话喂你
    2020-12-15 16:46

    How about :

    import ntpath
    import posixpath
    .
    .
    .
    dir = posixpath.join(*ntpath.split(s))
    .
    .
    

提交回复
热议问题