how to replace a substring in python code example
Example 1: python replace substring
txt = "I like bananas"
x = txt.replace("bananas", "apples")
print(x) # ----> I like apples
Example 2: python replace "\" for "/"
my_string = r'\\ServerA\DriveB\5.FolderC\A.TXT'
my_string = my_string.replace('\\', '/')
Example 3: python replace string
string.replace(old, new, count)