by zephyrfalcon · 16y ago · 0 comments
Since Windows paths use backslashes, you should either escape all of them (not just the \U), or use raw strings:
filename = "c:\\Users\\foo.txt"
filename = r"c:\Users\foo.txt"
As it happens, Unix-style forward slashes usually work fine too on Windows: filename = "c:/Users/foo.txt"
This way, you don't have to rename your files and directories. :-)Also, if the contents of the line are delimited by spaces, consider the split() method:
"a b c".split()
=> ["a", "b", "c"]
If the format isn't actually as easy as that, take a look at the re and csv modules.I really like that split thing. I'll have to do some more research into it. Figuring out how to do that and assign each split to its own variable and all...
Thanks a ton!