Python Random setstate() နည်းလမ်း
ဥပမာ
ကျပန်းနံပါတ်ဂျင်နရေတာ၏အခြေအနေကို ဖမ်းယူပြီး ပြန်လည်ရယူပါ-
import random
#print a random number:
print(random.random())
#capture the state:
state = random.getstate()
#print another
random number:
print(random.random())
#restore the state:
random.setstate(state)
#and the next random number should be the same
as when you captured the state:
print(random.random())
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
setstate()
ကျပန်းနံပါတ်ထုတ်လုပ်သူ၏အခြေအနေကို သတ်မှတ်ထားသောအခြေအနေသို့ ပြန်သွားရန်နည်းလမ်းကို အသုံးပြုသည် ။
getstate()
အခြေအနေကို ဖမ်းယူရန် နည်းလမ်းကို အသုံးပြုပါ။
အထားအသို
random.setstate(state)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
state | Required. A state object. the setstate() method will restore the state of the random number generator back to this sate. |