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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -