首页 > 其他分享 >json.dumps

json.dumps

时间:2023-02-09 14:23:25浏览次数:36  
标签:city name 19 age dumps json

  • separators:是分隔符的意思,参数意思分别为不同dict项之间的分隔符和dict项内key和value之间的分隔符,把:和,后面的空格都除去了。
1 2 3 4 5 6 7 8 9 10 11 import json   x = {'name':'你猜','age':19,'city':'四川'} #用dumps将python编码成json字符串 y = json.dumps(x) print(y) i = json.dumps(x,separators=(',',':')) print(i) # 输出结果 {"name": "\u4f60\u731c", "age": 19, "city": "\u56db\u5ddd"} {"name":"\u4f60\u731c","age":19,"city":"\u56db\u5ddd"}

标签:city,name,19,age,dumps,json
From: https://www.cnblogs.com/kxtomato/p/17105110.html

相关文章