Skip to main content

Python: Raw String

A Python raw string is a normal string, prefixed with a r or R.

This treats characters such as backslash (‘\’) as a literal character. This also means that this character will not be treated as a escape character.

This is useful when we want to have a string that contains backslash and don’t want it to be treated as an escape character.

Example:

raw_s = r'Hi\nHello'
print(raw_s)

Output: Hi\nHello

Tags
Submitted by devanshi.srivastava on July 13, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.