string literal python code example
Example 1: r string python
>>> print("This is a line feed : \n and it's usefull!")
This is a line feed :
and it's usefull!
>>> print(r"This is not a line feed /n :(")
This is not a line feed /n :(
my_path = "C:\Users\Me\Desktop\MyFile.txt"
my_path = r"C:\Users\Me\Desktop\MyFile.txt"
Example 2: python raw string
print(r"C\Users\MyName\Desktop")
print("C\\Users\\MyName\\Desktop")
Example 3: raw string python
>>> s = r'Hi\xHello'
>>> print(s)
Hi\xHello
Example 4: python literal string
String literal is a datatype in python.
which is used to store characters of variable length
For example :-
a = 'This is a string'
b = 'You can also includes these @#$%^&*( or 12345678'
Above there are two variables a and b having string literal as there values