我正在使用Python 2.7读取JSON文件。我的代码如下:
import json
from json import JSONDecoder
import os
path = os.path.dirname(os.path.abspath(__file__))+'/json'
print path
for root, dirs, files in os.walk(os.path.dirname(path+'/json')):
for f in files:
if f.lower().endswith((".json")):
fp=open(root + '/'+f)
data = fp.read()
print data.decode('utf-8')
但是我收到了以下错误消息:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf3 in position 72: invalid continuation byte
character-encoding
标签的百科全书以获取相关背景和故障排除技巧。 - tripleeeos.path.dirname()
将其删除,最后又再次添加回去呢? - tripleee