I would like to convert a string temp.filename.txt to temp.filename.txt using python
Tried string replace method but the output is not as expected
filename = "temp.filename.txt"
filename.replace(".", ".")
output: 'temp\.filename\.txt'
Advertisement
Answer
is a special character, which is represented as \, this doesn’t mean your string actually contains 2 characters.
(as suggested by @saipy, if you print your string, only single should show up…)