使用Python 3.5.1,我提取了一个文本文件,其中每一行都是JSON格式:{"a":"windows","b":"stairs"......}
import json
path = 'folder/data.txt'
records=[json.loads(line) for line in open(path,'rb')]
Run Code Online (Sandbox Code Playgroud)
但是我收到了错误:
the JSON object must be str, not 'bytes'
Run Code Online (Sandbox Code Playgroud)
我打印第一行文件没有问题,所以我确信文件路径是正确的.