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 :: send message in every channel discord.py 
Python :: pandas dataframe select columns multiple cell value 
Python :: Compress multiple directories but exclude directory - Python zipfile(or anything native to Windows 2012+ 
Python :: if is 
Python :: store dataframes 
Python :: merge csv files into one 
Python :: what does scalar.fit do 
Python :: seaborn colorbar labelsize 
Python :: problème barbier semaphore python 
Python :: if no python 
Python :: What is the right way to do such import 
Python :: how to map url with usernames prefixed 
Python :: variable bound to set python 
Python :: python compare number with a precision 
Python :: python complement operator 
Python :: element tree no able to find tag 
Python :: tkinter disabled but selectable 
Python :: how to deploy django app on heroku with mongodb 
Python :: python list insert out of range 
Python :: cuantas palabras hay en una frase en python 
Python :: convert python code to c++ online 
Python :: idiomatic python 
Python :: y level for iron 
Python :: tf.stop_gradient in pytorch 
Python :: KMeans 
Python :: python delete directory even if not empty 
Python :: how to add multiple commands to tkinter button 
Python :: what modules are used for NLG in python 
Python :: cannot cast type smallint to boolean django 
Python :: automl time series forecasting 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =