擅长:python、mysql、java
<p>问题是您使用的<a href="https://docs.python.org/3/library/stdtypes.html#bytes" rel="nofollow noreferrer">^{<cd1>} built-in in python3</a>与python2中的行为不同。在python2.7中,<code>bytes</code>是<code>str</code>的别名。在python3中,接受整数的构造函数生成一个n0数组。由于您传入了类似于<code>1,617,219,736,292</code>(2021年3月31日)的内容,因此您正在初始化一个大小为1.6万亿的数组并耗尽内存:<code>MemoryError </code></p>
<pre><code>$ python2
>>> print(bytes.__doc__)
str(object='') -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
^C
$ python3
>>> print(bytes.__doc__)
bytes(iterable_of_ints) -> bytes
bytes(string, encoding[, errors]) -> bytes
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
bytes(int) -> bytes object of size given by the parameter initialized with null bytes
bytes() -> empty bytes object
Construct an immutable array of bytes from:
- an iterable yielding integers in range(256)
- a text string encoded using the specified encoding
- any object implementing the buffer API.
- an integer
</code></pre>