How to dump json without quotes in python

后端 未结 5 2152
孤街浪徒
孤街浪徒 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:42

    Just use for loop to assign list to string.

    import json
    
    with open('json_file') as f:
        data = json.loads(f.read())
        for value_wo_bracket in data['key_name']:
            print(value_wo_bracket)
    

    Note there is difference between json.load and json.loads

提交回复
热议问题