How to replace special character in a file using Python?
Question:
I have data like this in file. I want replace the backslash from the entire data. I tried to use replace function after reading this text file but could not get the result. Could you please help.
[{"Name": "Segment1", "Value": 14.0, "Categories": "{"MILL CREEK": 0.0, "FAIRPORT": 1.0, "PENNINGTON": 0.0, "GREENWICH": 0.0
Answers:
you need to escape backslash char
str.replace('\', "")
I have data like this in file. I want replace the backslash from the entire data. I tried to use replace function after reading this text file but could not get the result. Could you please help.
[{"Name": "Segment1", "Value": 14.0, "Categories": "{"MILL CREEK": 0.0, "FAIRPORT": 1.0, "PENNINGTON": 0.0, "GREENWICH": 0.0
you need to escape backslash char
str.replace('\', "")