How to dump json without quotes in python

后端 未结 5 2164
孤街浪徒
孤街浪徒 2021-02-14 17:59

Here is how I dump a file

with open(\'es_hosts.json\', \'w\') as fp:
  json.dump(\',\'.join(host_list.keys()), fp)

The results is



        
5条回答
  •  执念已碎
    2021-02-14 18:41

    Use python's built-in string replace function

    with open('es_hosts.json', 'w') as fp:
       json.dump(','.join(host_list.keys()).replace('\"',''), fp)
    

提交回复
热议问题