If you are using a raw-string, then you do not escape backslashes:
f(r'E:\dir')
Of course, this problem (and many others like it) can be solved by simply using forwardslashes in paths:
f('E:/dir')
More Related Contents:
- Turn the whole file uppercase
- How do you append to a file?
- How to print a single backslash?
- Is explicitly closing files important?
- How to modify a text file?
- Confused by python file mode “w+”
- Iterating on a file doesn’t work the second time
- Directory-tree listing in Python
- How to write to a CSV line by line?
- How to delete the contents of a folder?
- Open file in a relative location in Python
- python replace single backslash with double backslash
- check what files are open in Python
- How to convert a file to utf-8 in Python?
- Python Regex escape operator \ in substitutions & raw strings
- Read from a log file as it’s being written using python
- Is close() necessary when using iterator on a Python file object [duplicate]
- Finding duplicate files and removing them
- Compare two files report difference in python
- Python 2.7: Print to File
- Reading files in a particular order in python
- Python Random Access File
- Best method for reading newline delimited files and discarding the newlines?
- Create a temporary FIFO (named pipe) in Python?
- How to replace a double backslash with a single backslash in python? [duplicate]
- Sending a file over TCP sockets in Python
- python write string directly to tarfile
- Is there a way to efficiently yield every file in a directory containing millions of files?
- Creating files and directories via Python
- Best way to choose a random file from a directory