python3 默认的是UTF-8格式,但在在用dump写入的时候仍然要注意:如下
import json
data1 = {
"TestId": "testcase001",
"Method...,
"passwd": "123456",
},
"Result": {
"errorno": "0"
}
}
with open('casedate.json...', 'w', encoding='utf-8') as f:
json.dump(data1, f, sort_keys=True, indent=4)
在打开文件的时候要加上encoding...},
"TestId": "testcase001",
"Title": "��¼����",
"Url": "http://xxx.xxx.xxx.xx"
}
在dump的时候也加上...",
"Title": "\u767b\u5f55\u6d4b\u8bd5",
"Url": "http://xxx.xxx.xxx.xx"
}
另外python3在向txt文件写中文的时候也要注意在打开的时候加上