'I always get an extra backslash when using them as escape sign in Python 3.7.11
The problem is very simple, when I input:
"\"\"'"
The output is
"""\'"
And when I input:
"C:\\Document\\code\\data1.csv"
The output is
"C:\\Document\\code\\data1.csv"
However, when I input:
r"C:\Documents\code\data2.csv"
The output is
"C:\\Documents\\code\\data2.csv"
Where did these extra backslashes come from? By the standard semantics of the backslash it acts as escape sign, but how could they "copy" itself and appears in the positions so that it seems like popped from nowhere?
Solution 1:[1]
OK, now I understood... When I simply put an "enter" after the command line, it returns me that very command.
If I place the string into functions like print(), then I will get the result I want.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Radiumpolonide |
