Answers for "what is r in python"

11

r"" python

# a Rstring is a string that treat backslashs as normals caracters
#Exemple:
#normal string
>>> print("This is a line feed : \n and it's usefull!")
This is a line feed :
and it's usefull!
# R-string
>>> print(r"This is not a line feed /n :(")
This is not a line feed /n :(
 
# It's mostly used to write Paths
# Exemple
my_path = "C:\Users\Me\Desktop\MyFile.txt" #Don't works a all but
my_path = r"C:\Users\Me\Desktop\MyFile.txt" #Totaly work!
Posted by: Guest on June-22-2020
0

what is r in python

# a normal string which treats a back slash as a special character and changes some properties of it
("D:\Users\legendary\Pictures\Saved Pictures\bugatti.jpg")

#we use r string to write paths without any conflit since they contain backshlases

# >>> this is an r string
(r"D:\Users\legendary\Pictures\Saved Pictures\bugatti.jpg")
Posted by: Guest on April-12-2021
-2

python carriage return

## In Python, you can put a carriage return into a string using '\r'.
## This is basically just a newline, and usually you would just use
## '\n'.
Posted by: Guest on August-07-2020

Python Answers by Framework

Browse Popular Code Answers by Language