windows - Unusual path joining in python's os library -


i trying in windows 8.1, python v.3.4. os.path module has join method which, according documentation, safe way join fragments of files or folders without mixing , forward slashes. in code snippet below trying join file , folder:-

>>> photo = r"\camera\picnic.jpg" >>> folder = os.getcwd() >>> print(folder) c:\users\renae >>> path = os.path.join(folder, photo) >>> print(path) c:\camera\picnic.jpg 

and boom goes dynamite. expecting path c:\users\renae\camera\picnic.jpg. i've tried removing r in front of photo no results. i've tried backslashes though windows uses forward slashes made worse. result mix of , forward slashes. if remember correctly not problem in linux.

try removing initial slash.

i can't speak windows because it's been long time since working on windows, in *nix systems, starting path slash signifies root of file system. i'm guessing implementation in python (and possibly more languages) use convention on windows well. don't have windows box verify on though.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -