correct way of using os.path.join() in python

前端 未结 1 1443
无人共我
无人共我 2021-01-18 04:17

I came across this python function os.path.join(). I wanted to know which was a preferred method of using it.

os.path.join(r\'C:\\\\\' , r\'some_dir_in_C_fol         


        
相关标签:
1条回答
  • 2021-01-18 04:39

    both are incorrect, the correct usage is(for eg: c:/programs/myfiles/cat.txt:

    >>> import os
    >>> os.path.join('C:/' , 'programs','myfiles','cat.txt') 
    'C:/programs/myfiles/cat.txt'
    
    0 讨论(0)
提交回复
热议问题