Python how to join cross platform paths -


if have json directory structure lists paths in mac format ()i.e. "/0000_test/video.mp4" , want join c:\\ mac format, there way this?

so on windows path returned c:\\0000_test\video.mp4"

i have tried os.path.join no avail

you can use os.path.join , os.path.normpath

>>> os.path.normpath(os.path.join('c:', '/0000_test/video.mp4')) 'c:\\0000_test\\video.mp4' 

normpath take care of normalizing path in platform specific manner.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -