glob python question.
Hello, I´m trying to get a list of files from a dir using glob. I get the list but the problem is that I get a path to the file this way: PATH_TO_FILE\\File.ext I mean, I use this to retrieve files: glob.glob("game/datasrc/*_at.tga") and I get files with this format: game/datasrc\\image.tga. why is this '\\' appearing in the file found?, is there anyway to get something like game\datasrc\image.tga directly?. Thanks in advance, HexDump.
It's a Windows/C idiosyncracy. Just take a look at os.path.sep and os.path.altsep, and use string.replace() to switch from one to the other.
For example:
For example:
>>> "C:\\Documents and Settings\\Oluseyi Sonaiya\\My Documents\\src".replace(os.path.sep, os.path.altsep)'C:/Documents and Settings/Oluseyi Sonaiya/My Documents/src'
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement