Python 将json文件作为输入读取,并作为pprint输出?
我正在处理一个大的json文件,该文件目前编码为一条长线 这使得其他人无法理解它,因此我想使用pprint渲染它 目前,我正在尝试导入完整文件并以Python 将json文件作为输入读取,并作为pprint输出?,python,data-processing,Python,Data Processing,我正在处理一个大的json文件,该文件目前编码为一条长线 这使得其他人无法理解它,因此我想使用pprint渲染它 目前,我正在尝试导入完整文件并以pprint格式打印,但我的输出如下所示: <_io.TextIOWrapper name='hash_mention.json' mode='r' encoding='UTF-8'> import pprint with open('./hash_mention.json', 'r') as input_data_file:
pprint
格式打印,但我的输出如下所示:
<_io.TextIOWrapper name='hash_mention.json' mode='r' encoding='UTF-8'>
import pprint
with open('./hash_mention.json', 'r') as input_data_file:
pprint.pprint(input_data_file)
您以读取模式打开文件,但忘记读取文件内容
只需将
pprint.pprint(输入数据文件)
更改为pprint.pprint(输入数据文件.read())
,瞧 pprint.pprint(输入数据文件)
-->pprint.pprint(输入数据文件.read())
你的操作系统是什么?我在用MacOSE你可以用answer。。。嗯