示例1:json_file=’/home/mashagua/my_pycharm/hr_plot/data/address.json’
with open(json_file,‘r’) as jf:
data=json.loads(jf)
错误1:TypeError: the JSON object must be str, bytes or bytearray, not ‘TextIOWrapper’
修改方法,把json.loads换成json.load
原因:理由是load是从文件里面load,loads是从str里面load,loads 是load string的简写。
错误2:JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig)
修改方法:json_file=’/home/mashagua/my_pycharm/hr_plot/data/address.json’
with open(json_file,‘r’,encoding=‘utf-8-sig’) as jf:
data=json.load(jf)
这种一般是编码格式有错,文件里是否有BOM的区别
参考文献:https://blog.csdn.net/w5688414/article/details/78811179
https://blog.csdn.net/gaifuxi9518/article/details/81047688