+ 10
How to convert a raw string into a normal string in Python?
I want to convert a raw string into a normal string. In the attached example https://code.sololearn.com/cOzEyLaN6gok/?ref=app I do this with the exec()-function in section #4. Could anybody please tell me a more elegant or alternative way to do this instead of doing this with exec()?
5 Antworten
+ 3
Try to decode using 'unicode-escape'.
d = c.encode().decode('unicode-escape')
+ 2
Lothar
No, that does not help.
+ 1
I am not sure if it helps:
https://stackoverflow.com/questions/2428117/casting-raw-strings-JUMP_LINK__&&__python__&&__JUMP_LINK
0
Maybe this would be helpful? 🤔
https://stackoverflow.com/questions/24242433/how-to-convert-a-raw-string-into-a-normal-string