I have a problem when trying to convert a string containing special characters to a list using a split and save result to josn. For example:
t="machine,machine\c&"
p=t.split(",")
host = {}
host['name'] = p[0]
host['filespace'] = p[1]
with open('json_host.json', 'w') as file:
json.dump(host, file, indent=4)
return:
{
"name": "machine",
"filespace": "machine\\c&"
}
I need the return conver only one \
{
"name": "machine",
"filespace": "machine\c&"
}
I have tried to use a replace but it does not work