Answers for "backslash in python string"

28

reverse string in python

'hello world'[::-1]
'dlrow olleh'
Posted by: Guest on December-06-2019
10

backslash in python

In python a backslash is used a an escape character, if you want to
include a tab, newline, quote or any unicode character, you must use a
backslash.

''' - quote
'"' - double quote
'n' - newline
't' - tab
'r' - carriage return
'\' - backslash
'u...' - unicode character (replace ... with the corresponding 4-digit number)
'b' - backspace
'f' - form feed
'ooo...' octal value (replace ...)
'x..' hexadecimal value (replace .. with two characters)
Posted by: Guest on April-07-2021
1

python3 strip punctuation from string

import string
#make translator object
translator=str.maketrans('','',string.punctuation)
string_name=string_name.translate(translator)
Posted by: Guest on May-19-2020
0

string to list in python comma

# input comma separated elements as string 
str = str (raw_input ("Enter comma separated integers: "))
print "Input string: ", str

# conver to the list
list = str.split (",")
print "list: ", list
Posted by: Guest on April-27-2020
15

python replace char in string

# Python3 program to demonstrate the  
# use of replace() method   
  
string = "geeks for geeks geeks geeks geeks" 
   
# Prints the string by replacing geeks by Geeks  
print(string.replace("geeks", "Geeks"))  
  
# Prints the string by replacing only 3 occurrence of Geeks   
print(string.replace("geeks", "GeeksforGeeks", 3))
Posted by: Guest on March-10-2020
1

python backslash in string

# This will output one backslash
print("\")
# OUTPUT:
Posted by: Guest on February-07-2021

Code answers related to "backslash in python string"

Python Answers by Framework

Browse Popular Code Answers by Language