<legend id='X0NJH'><style id='X0NJH'><dir id='X0NJH'><q id='X0NJH'></q></dir></style></legend><tfoot id='X0NJH'></tfoot>
  • <i id='X0NJH'><tr id='X0NJH'><dt id='X0NJH'><q id='X0NJH'><span id='X0NJH'><b id='X0NJH'><form id='X0NJH'><ins id='X0NJH'></ins><ul id='X0NJH'></ul><sub id='X0NJH'></sub></form><legend id='X0NJH'></legend><bdo id='X0NJH'><pre id='X0NJH'><center id='X0NJH'></center></pre></bdo></b><th id='X0NJH'></th></span></q></dt></tr></i><div id='X0NJH'><tfoot id='X0NJH'></tfoot><dl id='X0NJH'><fieldset id='X0NJH'></fieldset></dl></div>

      • <bdo id='X0NJH'></bdo><ul id='X0NJH'></ul>
      1. <small id='X0NJH'></small><noframes id='X0NJH'>

        OSError: [Errno 22] 当我尝试 .read() 一个 json 文件时

        OSError: [Errno 22] when I try to .read() a json file(OSError: [Errno 22] 当我尝试 .read() 一个 json 文件时)

        <small id='TF07D'></small><noframes id='TF07D'>

        <i id='TF07D'><tr id='TF07D'><dt id='TF07D'><q id='TF07D'><span id='TF07D'><b id='TF07D'><form id='TF07D'><ins id='TF07D'></ins><ul id='TF07D'></ul><sub id='TF07D'></sub></form><legend id='TF07D'></legend><bdo id='TF07D'><pre id='TF07D'><center id='TF07D'></center></pre></bdo></b><th id='TF07D'></th></span></q></dt></tr></i><div id='TF07D'><tfoot id='TF07D'></tfoot><dl id='TF07D'><fieldset id='TF07D'></fieldset></dl></div>

            • <bdo id='TF07D'></bdo><ul id='TF07D'></ul>

                <legend id='TF07D'><style id='TF07D'><dir id='TF07D'><q id='TF07D'></q></dir></style></legend>
              1. <tfoot id='TF07D'></tfoot>
                  <tbody id='TF07D'></tbody>

                  本文介绍了OSError: [Errno 22] 当我尝试 .read() 一个 json 文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我只是想在 Python 中读取我的 json 文件.当我这样做时,我在正确的文件夹中;我在下载中,我的文件名为Books_5.json".但是,当我尝试使用 .read() 函数时,我得到了错误

                  I am simply trying to read my json file in Python. I am in the correct folder when I do so; I am in Downloads, and my file is called 'Books_5.json'. However, when I try to use the .read() function, I get the error

                  OSError: [Errno 22] Invalid argument
                  

                  这是我的代码:

                  import json
                  config = json.loads(open('Books_5.json').read())
                  

                  这也会引发同样的错误:

                  This also raises the same error:

                  books = open('Books_5.json').read()
                  

                  如果有帮助,这是我的数据的一小部分:

                  If it helps, this is a small snippet of what my data looks like:

                  {"reviewerID": "A10000012B7CGYKOMPQ4L", "asin": "000100039X", "reviewerName": "Adam", "helpful": [0, 0], "reviewText": "Spiritually and mentally inspiring! A book that allows you to question your morals and will help you discover who you really are!", "overall": 5.0, "summary": "Wonderful!", "unixReviewTime": 1355616000, "reviewTime": "12 16, 2012"}
                  {"reviewerID": "A2S166WSCFIFP5", "asin": "000100039X", "reviewerName": "adead_poet@hotmail.com "adead_poet@hotmail.com"", "helpful": [0, 2], "reviewText": "This is one my must have books. It is a masterpiece of spirituality. I'll be the first to admit, its literary quality isn't much. It is rather simplistically written, but the message behind it is so powerful that you have to read it. It will take you to enlightenment.", "overall": 5.0, "summary": "close to god", "unixReviewTime": 1071100800, "reviewTime": "12 11, 2003"}
                  

                  我在 MacOSX 上使用 Python 3.6

                  I'm using Python 3.6 on MacOSX

                  推荐答案

                  看来这是文件太大时出现的某种错误(我的文件是~10GB).一旦我使用 split 将文件分成 200 k 行,.read() 错误就会消失.即使文件不是严格的 json 格式也是如此.

                  It appears that this is some kind of bug that occurs when the file is too large (my file was ~10GB). Once I use split to break up the file by 200 k lines, the .read() error goes away. This is true even if the file is not in strict json format.

                  这篇关于OSError: [Errno 22] 当我尝试 .read() 一个 json 文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                  <i id='NRThp'><tr id='NRThp'><dt id='NRThp'><q id='NRThp'><span id='NRThp'><b id='NRThp'><form id='NRThp'><ins id='NRThp'></ins><ul id='NRThp'></ul><sub id='NRThp'></sub></form><legend id='NRThp'></legend><bdo id='NRThp'><pre id='NRThp'><center id='NRThp'></center></pre></bdo></b><th id='NRThp'></th></span></q></dt></tr></i><div id='NRThp'><tfoot id='NRThp'></tfoot><dl id='NRThp'><fieldset id='NRThp'></fieldset></dl></div>
                1. <legend id='NRThp'><style id='NRThp'><dir id='NRThp'><q id='NRThp'></q></dir></style></legend>
                      • <small id='NRThp'></small><noframes id='NRThp'>

                        <tfoot id='NRThp'></tfoot>

                            <bdo id='NRThp'></bdo><ul id='NRThp'></ul>
                              <tbody id='NRThp'></tbody>