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 :: where are python libraries installed in windows 
Python :: get only first 10 columns pandas 
Python :: python moving average pandas 
Python :: get guild by id discord.py 
Python :: assign python 
Python :: python socket check if still connected 
Python :: django updated_at field 
Python :: get a slice of string in python 
Python :: cant install tensorflow pip python 3.6 
Python :: how to create window in tkinter 
Python :: how to create a list in python 
Python :: manipulate ip address in python 
Python :: Read text file line by line using the readline() function 
Python :: pandas gropu by 
Python :: python returen Thread 
Python :: python subtract lists 
Python :: close python window after execution 
Python :: .encode python 
Python :: how download youtube video in python 
Python :: how to do a square root in python 
Python :: how to make getter in python 
Python :: scikit learn lda 
Python :: how to find 1 st digit in python 
Python :: sort a string in python 
Python :: check if path exists python 
Python :: delete values with condition in numpy 
Python :: python if elif else in one line 
Python :: python remove whitespace from start of string 
Python :: how to sort a dictionary py 
Python :: boto3 delete bucket object 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =