dimanche 22 février 2015

Convert string stored in variable to raw string

I want to convert a string, which contains a file path, to a raw string, so the '\' characters are not considered escapes.



path = 'c:\Users'
# how to now change path to raw string?


So if I'm using something like this in Python 3, can I convert path to a raw string? I've tried using the encode method for strings, but that does not work. Also, I am not looking for solutions to replace the string '\' with '\'. I feel this process would take too long for how many paths I would have to process. So are there any simple conversions to convert path into a raw string?


Aucun commentaire:

Enregistrer un commentaire