Apr-21-2020, 03:47 PM
(This post was last modified: Apr-21-2020, 03:47 PM by deanhystad.)
The backslash character has special meaning (escape character), and python is inserting another backslash to say "The next backslash is just a backslash". I do not know why this is necessary, but it must be for some reason. Interestingly python only does this when the next letter is not part of a escape sequence. For example, if I use a value that starts with \n or \r, these do not get the extra backslash. My guess is python is doing you a favor and automatically adding the extra backslash to prevent anyone from treating it as an invalid escape sequence. You should be adding the extra backslash yourself.
It is easy to print out an entire dictionary. And you can use much nicer formatting if you want.
It is easy to print out an entire dictionary. And you can use much nicer formatting if you want.
for key, value in dict.items() print(key, value)Just thought of something you could do. Use a raw string. A backslash in a raw string is just a backslash. That must be what Python is doing, saving dictionary keys as raw strings.