numpy.random.Generator.bytes#

方法

random.Generator.bytes(length)#

返回随机字节.

参数:
lengthint

随机字节数.

返回:
outbytes

长度为 length 的字符串.

备注

此函数从离散均匀分布中生成随机字节.生成的字节与CPU的本机字节序无关.

示例

>>> rng = np.random.default_rng()
>>> rng.bytes(10)
b'\xfeC\x9b\x86\x17\xf2\xa1\xafcp'  # random