2

I have a requirement in which i have to specify a file path of an object (say 'abcd.jpg'). I am able to find the path with os module in python. But it contains '\\' as a separator. How to convert this separator to '\'.

>>> import os
>>> a = os.getcwd() + '\\' + 'abcd.jpg'
>>> a
'C:\\Python27\\abcd.jpg'

In my script i am only allowed to write the path name as 'C:\Python27\abcd.jpg'

Jon Clements
  • 138,671
  • 33
  • 247
  • 280
Deepak Kumar
  • 109
  • 1
  • 1
  • 12

1 Answers1

1

Just do print a and you should be fine. What you are doing is actually the repr of the string.