I used os.join.path() to load image in a folder. But I found the function cannot give accurate path when it is used in defining another function in some cases. For example:
def Myfuncion(something)
desiredPath = os.path.join('myPath','apple.jpeg')
#desiredPath = os.path.normpath(os.path.join('myPath','apple.jpeg'))
print desiredPath
return
When I implement the function, the printed result of the path is:
myPath\apple.jpeg
It is illegal for image loading. But os.path.join() works well in Pythonconsole.
How to make the path generated in such function definition have double backslashes?
Also, it is noted os.path.normpath also cannot work well sometimes. For example:
os.path.normpath('myPath\apple')
It should give the result:
myPath\\apple
But instead, it results in:
'myPath\x07pple'
How come??