两种 dumps 差多少
同一份汇总,一次默认 dumps,一次带上两个参数。运行程序,看长度和中文:
import json
t = {"东门": 44.0, "北门": 10.0}
a = json.dumps(t)
b = json.dumps(t, ensure_ascii=False, indent=2)
print(str("东门" in a) + "/" + str("东门" in b) + "/" + str(b.count("\n")))
同一份汇总,一次默认 dumps,一次带上两个参数。运行程序,看长度和中文:
import json
t = {"东门": 44.0, "北门": 10.0}
a = json.dumps(t)
b = json.dumps(t, ensure_ascii=False, indent=2)
print(str("东门" in a) + "/" + str("东门" in b) + "/" + str(b.count("\n")))
全部评论