Emanuel Barry added the comment:

(Berker beat me to it, but posting anyway since it is more detailed)

Backslashes are escape characters, and "\b" is treated as "\x08". Invalid 
combinations (e.g. "\A", "\D"...) automatically escape the backslash, but you 
shouldn't rely on this behaviour - as you can see, it can break in various ways.

To fix your issue, you can either:

- Add a single 'r' before the beginning of your string, i.e. 
r"C:\Users\Anwender\Desktop\Test\blub.txt" - the 'r' prefix tells Python to 
automatically escape all backslashes it sees (unless it's at the end of the 
string, in that case you need to escape it yourself).

- Escape each backslash in your string, i.e. 
"C:\\Users\\Anwender\\Desktop\\Test\\blub.txt" - the extra backslash tells 
Python "treat this as a literal backslash, don't use it to escape anything"

- Since this is Windows, you can use forward slashes, i.e. 
"C:/Users/Anwnder/Desktop/Test/blub.txt", it will work all the same for Python.

----------
nosy: +ebarry

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27356>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to