Reputation: 529
If I have a string like this:
str = C:\Users\PB\Desktop\Arsiv
How can I append character '\' in this string like this:
str = C:\\Users\\PB\\Desktop\\Arsiv
Upvotes: 0
Views: 50
Reputation: 120
You might try raw strings by using an r or R prefix.
str = r'C:\\Users\\PB\\Desktop\\Arsiv'
Upvotes: 1
Reputation: 3806
You'll need to escape the \ . So, for every instance of a backslash character, replace it with 2 backslash characters.
astr.replace("\\", "\\\\")
Upvotes: 1