Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
I am currently working with a string variable named 's'. I want to make it a raw string. How can I convert a normal string into a raw string?

1 Answer

0 votes
by (107k points)

I  think you are referring to the str.encode("string-escape") method. Let's say you are having a variable that you want to convert to 'raw string':

a = '\x89'

a.encode('unicode_escape')

'\\x89'

One important piece of information that you can only use string-escape for python 2.x and older versions.

If you are a beginner and want to know more about Python, then do refer to the Python certification.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...