[英]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 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.