raw string
Patrick Useldinger
p at trick.lu
Sat Sep 20 15:42:16 EDT 2003
On Sat, 20 Sep 2003 21:10:46 +0200, Marc Petitmermet
<petitmermet at mat.ethz.ch> wrote:
>I can do the following replacement:
>
>r"kr\xdf6;ger".replace('\\','&#')
>-> '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".replace('\\','&#')
>-> 'r"name"
name = r"kr\xdf6;ger" (the r goes here)
name.replace('\\','&#') (the name of the object must not be in quotes)
-PU
More information about the Python-list
mailing list