本节内容

1、生成json文件
2、读取json文件

一、生成json文件

a = [{"kk":111, "dd":"f"}]

# 写json文件
with open("test.json", 'w',encoding='utf-8') as f:
    json.dump(a, f,ensure_ascii=False)
    print("加载入文件完成...")

二、读取json文件

with open("./test.json",'r', encoding='utf-8') as load_f:
        load_dict = json.load(load_f)  # 转换成json字符串
        print(type(load_dict))
Categories: 文件操作

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *