1、特殊符號 \n 的轉換邏輯
import json x = {'test': "測試\n"} # python 中的字典結構 x_json = json.dumps(x, ensure_ascii=False) x_json # '{"test": "測試\\n"}' 這里看上去稍微有一點特殊,本質就是轉義 json 字符串。 print(x_json) # {"test": "測試\n"} #