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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -