David C. Fox
davidcfox at post.harvard.edu
Sat Sep 20 21:29:30 CEST 2003
Marc Petitmermet wrote:
> I can do the following replacement:
> -> 'kr෶ger'
> But how can I do this using a variable which contains the above string?
> Obviously, the following code returns not the string with replacement
> but the name of the variable itself:
> name = "kr\xdf6;ger"
> -> 'r"name"
name = r"kr\xdf6;ger"
If you say name = "kr\xdf6;ger" without the r prefix, the \x has already
been replaced with a single character, and there is no slash in the
string, so it is too late to try to replace a slash with something else.
More information about the Python-list