python find and replace in string code example
Example 1: python replace "\" for "/"
my_string = r'\\ServerA\DriveB\5.FolderC\A.TXT'
my_string = my_string.replace('\\', '/')
Example 2: python replace matching string
s = 'one two one two one'
# 1st argument: string to find
# 2nd argument: string to put in place
print(s.replace(' ', '-')) # one-two-one-two-one