How to read from a JSON file with unescaped backslashes?
问题 I have a JSON file that contains a connection string: abc.json { "host":"1.2.3.4", "user":"abc", "passwd":"s&]\yz$&u42/", "dbname":"sample", "port":2341 } Here's my Python script which tries to read the data: import psycopg2 as pg dbconn = "C:\abc.json" with open(dbconn) as conn_file: conn = json.load(conn_file) It gives me this error: json.decoder.JSONDecodeError: Invalid \escape: line 4 column 16 (char 53) How can I fix this error? 回答1: Your file is not valid: there's no such escape