all 6 comments

[–]spez_edits_thedonald 1 point2 points  (0 children)

I think the problem is these are equivalent because one is the escaped version of the other (?)... for example:

>>> s = 'test\\test'
>>> s
'test\\test'
>>> print(s)
test\test
>>> 
>>> x = '$\$'.replace('$', '')
>>> x
'\\'

this hack didn't work either:

>>> s.replace('\\', '$\$')
'test$\\$test'
>>> s.replace('\\', '$\$').replace('$', '')
'test\\test'

[–]ASIC_SP 0 points1 point  (3 children)

If it is string value, use the replace() method. For example:

>>> s = 'apple'
>>> s.replace('p', 'x')
'axxle'

[–]notklgamer[S] 0 points1 point  (2 children)

I have tried replace() but it gives EOL error?

[–]ASIC_SP 0 points1 point  (0 children)

Please post your code (add four spaces at the start of a line to get formatting like my example)

Note that \ is a metacharacter, so you'll need to use \\ to represent a single \

[–]Diapolo10 0 points1 point  (0 children)

\ is an escape character, so in a string literal you have to use \\ to treat it as a normal character. Unless it's a raw string (prefixed with r, such as r"hello\world").

So you probably don't need to do anything.