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 :: reshape (n ) to (n 1) 
Python :: python float range 
Python :: python how to convert a list of floats to a list of strings 
Python :: how to pop an exact number from a list in python 
Python :: authentication views django 
Python :: How to Connect Google Colab to a Local Jupyter Runtime 
Python :: how to use sort in python 
Python :: .counter python 
Python :: python3 call parent constructor 
Python :: reading from a file in python 
Python :: how to get only one column from dataset in python 
Python :: python outlook 
Python :: how to use prettytable in python 
Python :: change column values based on another column pandas 
Python :: pandas split list in column to rows 
Python :: lamda in pyton 
Python :: multiple channel deleteing command in discord.py 
Python :: {% load humanise %} 
Python :: how to get input from user in pyqt5 
Python :: Static Language Programmers 
Python :: pandas fillna 
Python :: append more columns into a 2d array 
Python :: lemmatization in nlp 
Python :: get hex code of character python 
Python :: [<matplotlib.lines.Line2D object at 0x7fee51155a90] 
Python :: python rock paper scissors game 
Python :: how to import matplotlib in python 
Python :: python gitignore 
Python :: how stract avery .jpg string in a website python 
Python :: sns boxplot ylabelsize 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =