简体   繁体   English

TypeError:open()获得了意外的关键字参数“缓冲”

[英]TypeError: open() got an unexpected keyword argument 'buffering'

I am writing a chatbot program with python and when I run my code I get the following error. 我正在用python编写chatbot程序,当我运行代码时,出现以下错误。

Traceback (most recent call last):
  File "C:/Users/stephen/AppData/Local/Programs/Python/Python35/chatbot.py", line 97, in <module>
    with bz2.open("C:/RC_{}".format(timeframe.split('-')[0],timeframe), buffering=1000) as f:
TypeError: open() got an unexpected keyword argument 'buffering'

Could not find any information online regarding error. 找不到在线有关错误的任何信息。 All I saw was maybe that it was a bug and I should report it to python. 我所看到的只是它是一个错误,我应该将其报告给python。 Currently running python3.5.3. 当前正在运行python3.5.3。 This is the part of the code that gets the error. 这是获取错误的代码部分。

with bz2.open("C:/RC_{}".format(timeframe.split('-')[0],timeframe), buffering=1000) as f:
    for row in f:
        row_counter += 1
        parent_id = row['parent_id']
        body = format_data(row['body'])
        created_utc = row['created_utc']
        score = row['score']
        comment_id = row['name']
        subreddit = row['subreddit']
        parent_data = find_parent(parent_id)

The error is very explicit: 该错误非常明显:

TypeError: open() got an unexpected keyword argument 'buffering'

A simple check of the documentation for bz2.open would then show you that this function does not take a buffering argument. 简单检查一下bz2.open的文档,就会发现该函数没有buffering参数。

So simply remove it. 因此,只需将其删除。

The bz2.open function doesn't take a buffering argument. bz2.open函数不带buffering参数。 Even bz2.BZ2File , which takes buffering , explicitly notes: 甚至需要buffering bz2.BZ2File也明确指出:

The buffering argument is ignored. buffering参数将被忽略。 Its use is deprecated. 不建议使用它。

Buffering arguments are a bit nonsensical for compressors; 缓冲参数对于压缩器来说有点荒谬。 they have to buffer to some extent, since if you request X amount of data, they may need need to decompress a block of unknown final size to get it, so they're either decompressing the whole block and buffering the uncompressed data beyond the X request, or stopping decompression when they reach X, buffering the compressed data (and they might still have to buffer some uncompressed data since decompressing a single byte from a stream can produce many bytes of output). 它们必须缓冲到一定程度,因为如果您请求X数量的数据,则可能需要解压缩最终大小未知的块才能获得它,因此,他们要么解压缩整个块,然后将未压缩的数据缓冲到X之外。请求,或者当它们到达X时停止解压缩,以缓冲压缩的数据(由于从流中解压缩单个字节会产生许多字节的输出,它们可能仍必须缓冲一些未压缩的数据)。

Point is, there is no reasonable way to disable or limit buffering; 重点是,没有合理的方法来禁用或限制缓冲; the needs of the compressor mean you don't have that level of control. 压缩机的需求意味着您没有那种控制水平。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:得到一个意外的关键字参数 - TypeError: got an unexpected keyword argument “TypeError: open() 在我的解析代码中得到了一个意外的关键字参数‘换行符’” - “TypeError: open() got an unexpected keyword argument 'newline'” in my parsing code httplib_response = conn.getresponse(buffering = True)TypeError:getresponse()使用Selenium获得了意外的关键字参数&#39;buffering&#39;? - httplib_response = conn.getresponse(buffering=True) TypeError: getresponse() got an unexpected keyword argument 'buffering' using Selenium? TypeError:得到了意外的关键字参数“ name” - TypeError: got an unexpected keyword argument “name” 类型错误:binarySearch() 得到了一个意外的关键字参数“key” - TypeError: binarySearch() got an unexpected keyword argument 'key' TypeError:histogram()得到了意外的关键字参数“ new” - TypeError: histogram() got an unexpected keyword argument 'new' TypeError:urlopen()获得了意外的关键字参数&#39;headers&#39; - TypeError: urlopen() got an unexpected keyword argument 'headers' TypeError:得到了一个意外的关键字参数“图像” - TypeError: got an unexpected keyword argument 'image' TypeError: concatenate() 得到了一个意外的关键字参数“dtype” - TypeError: concatenate() got an unexpected keyword argument 'dtype' TypeError: mannwhitneyu() 得到了一个意外的关键字参数“方法” - TypeError: mannwhitneyu() got an unexpected keyword argument 'method'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM