numpy.random.RandomState.bytes#

方法

random.RandomState.bytes(length)#

返回隨機位元組。

注意

新程式碼應使用 bytes 方法,此方法屬於 Generator 實例;請參閱快速入門

參數:
lengthint

隨機位元組的數量。

返回:
outbytes

長度為 length 的字串。

參見

random.Generator.bytes

新程式碼應使用此方法。

範例

>>> np.random.bytes(10)
b' eh\x85\x022SZ\xbf\xa4' #random