小编Agb*_*ent的帖子

如何在实例之间共享随机数?

import random

class Unique_Key(object):
def __init__(self):
    self.uni_k =random.randint(1, 1000000)
    


unique_key_obj1=Unique_Key()
print(f"First Record {unique_key_obj1.uni_k}")


unique_key_obj=Unique_Key()
print(f"Second Record {unique_key_obj.uni_k}")
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我如何使unique_key_obj1对象的值与对象的值相同unique_key_obj吗?谢谢!

python random function

0
推荐指数
1
解决办法
51
查看次数

标签 统计

function ×1

python ×1

random ×1