Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

escape character in python

#You will get an error if you use double quotes inside a string 
#that is surrounded by double quotes:

txt = "We are the so-called "Vikings" from the north."

#To fix this problem, use the escape character ":
txt = "We are the so-called "Vikings" from the north."

#Output: We are the so-called "Vikings" from the north.
Comment

what are the escape characters in python

Please thank, like, use in you code and improve!!!
#Enclosing quotes with qoutes of the same kind terminates the string prematurely.
#Hence, escape such errors using the escape character(backslash).
word = ""I am a boy", he said."# Terminates the string prematurely.
#Outputs , he said.
word = ""I am a boy", he said"
print(word)# Outputs "I am a boy, he said.
Types of escape characters:
  
 - newline		 - tab spacing	
 - carriage return	
   creates a backslash since one backslash is used to escape
#However using different quotes does no damage to the code.
word = '"I am a boy", he said.'
#Outputs "I am a boy", he said.
I hope I've helped you guys understand the topic better.
Bye, see you soon!!!
Comment

python escape character example

>>> spam = 'Say hi to Bob's mother.'
Comment

PREVIOUS NEXT
Code Example
Python :: pyplot python 
Python :: match python 3.10 
Python :: run in thread decorator 
Python :: xlabel and ylabel in python 
Python :: python print value and variable name 
Python :: how to do a print statement in python 
Python :: disable close button in tkinter 
Python :: flask wtforms multiple select 
Python :: python functions with input 
Python :: vim run python current file 
Python :: how to push item to array python 
Python :: tensorflow matrix multiplication 
Python :: Cast image to float32 
Python :: decimal to binary in python 
Python :: if substring not in string python 
Python :: python argparse optional required 
Python :: flatten tf keras 
Python :: group by pandas count 
Python :: read csv file with pandas 
Python :: how to delete an item from a list python 
Python :: pandas xa0 
Python :: capitalize first letter of each word python 
Python :: django textfield 
Python :: python replace null in list 
Python :: convert plt image to numpy 
Python :: sentence similarity spacy 
Python :: flask error handling 
Python :: bulk create django 
Python :: upload to test pypi 
Python :: python imaplib send email 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =