Вот MWE:
Код: Выделить всё
import random
import json
if __name__ == '__main__':
random.seed()
random_state = random.getstate()
json_state = json.dumps(random_state)
restored_state = json.loads(json_state)
random.setstate(restored_state)
Код: Выделить всё
Traceback (most recent call last):
File "/home/paul/PycharmProjects/mwe/main.py", line 10, in
random.setstate(restored_state)
File "/usr/lib/python3.12/random.py", line 182, in setstate
super().setstate(internalstate)
TypeError: state vector must be a tuple
Process finished with exit code 1
Подробнее здесь: https://stackoverflow.com/questions/792 ... using-json
Мобильная версия