Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python print raw string

>>> print(repr('abc 123 
'))
'abc 123 
'
Comment

python raw string

#A raw string considers backslash as literal instead of an escape character
print(r"CUsersMyNameDesktop")
#Without the r in front you will have to escape the  with another 
print("CUsersMyNameDesktop")
#Both will print the same thing "CUsersMyNameDesktop"
Comment

raw string python


>>> s = r'HixHello'
>>> print(s)
HixHello
Comment

Python raw strings

'''
Windows paths for files contain backslashes which python interprets as
escape sequences. To ignore these escape sequences, you can use raw strings!
'''

import os

# os.chdir changes the current working directory
os.chdir("C:UsersUSERNAMEDesktop") # Creates error

INSTEAD, USE:
os.chdir(r"C:UsersUSERNAMEDesktop") # Add an r before the string
Comment

PREVIOUS NEXT
Code Example
Python :: create an array of n same value python 
Python :: python talib install windows 
Python :: RuntimeError: Broken toolchain: cannot link a simple C program 
Python :: converting decimal to hex in python 
Python :: dataframe move row up one 
Python :: split a string by comma in python 
Python :: convert python datetime to string 
Python :: python list comprehension cartesian product 
Python :: how to press enter in selenium python 
Python :: print() 
Python :: check object type python 
Python :: python iterate through files 
Python :: test split 
Python :: reading json file in python 
Python :: split a variable into multiple variables in python 
Python :: list files python 
Python :: python get last element of list 
Python :: time py 
Python :: python data structures 9.4 
Python :: fstring 
Python :: django unique together 
Python :: django get settings 
Python :: __file__ python 
Python :: convert a dictionary to pandas dataframe 
Python :: django boilerplate command 
Python :: python pdf fpdf example 
Python :: openpyxl full tutorial 
Python :: python remove everything after character 
Python :: root mean squared error 
Python :: python create file if doesnt exist 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =