+ 2
How can I print the \ character in python?
6 Answers
+ 7
There is also an other possible solution. (Kirian Deep Naidu, you have been faster!)
my_str = r'hello \\world\n' # this is a raw-string
print(my_str)
# output = 'hello \\world\n' (quotes are not printed)
+ 3
print("\\")
+ 2
Chwenkam Adrian
You need to escape your backslash by preceding it with, another backslash:
Example:
print("\\")
+ 1
you need to scape it using double \\
+ 1
Yeah it works. Thanks!
0
It actually annuls the " in print("\"). I would like to create a house with it.