python load json

import json
# jsonPath = r'D:/PythonProject/Editor/main/template2.json';
jsonPath = r'D:/PythonProject/Editor/main/template.json';


def load():
    with open(jsonPath,'r') as f:
        data = json.load(f)
        return data

data = load()

遇到的麻烦:

 

解决方案如下:

 

 

 

jsonPath = 'X:\x\c\info.json'
with open(jsonPath, 'r',encoding='UTF-8') as f:
    data = json.load(f)
 
posted @ 2020-05-13 17:09  bH1pJ  阅读(37)  评论(0编辑  收藏  举报