<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 文件时

        时间:2023-09-29

        <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 文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:根据日期将数据框拆分为两个 下一篇:来自多个 HDF5 文件/数据集的链数据集

                  相关文章

                  <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>
                  1. <small id='NRThp'></small><noframes id='NRThp'>

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

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