python处理json文件

代码如下:
In : f = open('E:/python/data.json','r+')

In : f
Out : <_io.TextIOWrapper name='E:/python/data.json' mode='r+' encoding='cp936'>
这个输出是什么意思?

In :a = pd.Series(f)

TypeError Traceback (most recent call last)
<ipython-input-10-de5589147c94> in <module>()
----> 1 a = pd.Series(f)

E:Anacondalibsite-packagespandascoreseries.py in __init__(self, data, index, dtype, name, copy, fastpath)

235                 if not is_list_like(data):
236                     data = [data]

--> 237 index = _default_index(len(data))

238 
239             # create/copy the manager

TypeError: object of type '_io.TextIOWrapper' has no len()
出现错误不知道怎么修改,帮帮忙!

阅读 4k
2 个回答
Out : <_io.TextIOWrapper name='E:/python/data.json' mode='r+' encoding='cp936'> 

# 这个是个文件对象

pandas 不熟,其余的就不知道了

is_list_like是什么?怎么定义的?报错信息是说data的值是_io.TextIOWrapper这个玩意,并不是list,所以len(data)不对

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题