import json
data ={
'name': liangliang,
'age': 30,
'gender': male,
'address:', beijing
}
json_str = json.dumps(data, ensure_ascii=False, indent=4) #字符缩进4
json_path = './xxx.json'
with open(json_path, 'w') as json_file:
json_file.write(json_str)