Python Random getstate() Method

❮ Random Methods


Example

Return the current state of the random generator:

import random

print(random.getstate())
Try it Yourself »

Definition and Usage

The getstate() method returns an object with the current state of the random number generator.

Use this method to capture the state, and use the setstate() method, with the captured state, to restore the state


Syntax

random.getstate()

Parameter Values

No parameter values


❮ Random Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.