Python Random getrandbits() Methode
Beispiel
Geben Sie eine 8-Bit-Ganzzahl zurück:
import random
print(random.getrandbits(8))
Definition und Verwendung
Die getrandbits()
Methode gibt eine Ganzzahl in der angegebenen Größe (in Bits) zurück.
Syntax
random.getrandbits(n)
Parameterwerte
Parameter | Description |
---|---|
n | Required. A number specifying the size, in bits, of the returned integer. |