Pythonランダムgetrandbits()メソッド
例
8ビットサイズの整数を返します。
import random
print(random.getrandbits(8))
定義と使用法
このgetrandbits()
メソッドは、指定されたサイズ(ビット単位)の整数を返します。
構文
random.getrandbits(n)
パラメータ値
Parameter | Description |
---|---|
n | Required. A number specifying the size, in bits, of the returned integer. |