Q:

python replace "\" for "/"

string.replace(old, new, count)
# Only return a copy, not modifying the string
25
# 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)) 
4
string = "[Message]"
string = string.replace("[", "")#Removes all [
string = string.replace("]", "")#Removes all ]

print(string)
1
# Simple replacement
str.replace(old, new, count)

# Multi-match replacement
import re
STRING = re.sub("(\.fasta|\.fna)","", STRING)
1
plot.savefig(f'hanning{num}.pdf') # added in Python 3.6
0
my_string = r'\\ServerA\DriveB\5.FolderC\A.TXT'
my_string = my_string.replace('\\', '/')
0

New to Communities?

Join the community