def get_mobile():
mobiles = ['130', '131', '132', '133', '134', '135', '136', '155', '156', '157', '157', '159']
number = str(int(time.time()))[2:]
# 使用python自带的时间戳进行截取(因为时间戳每次都不相同,所有可以用作随机生成)
print(str(int(time.time())))
# 随机选择random.choice()
mobile = random.choice(mobiles) + number
print(mobile)
python学习记录之如何随机生成手机号
最新推荐文章于 2023-01-07 20:37:53 发布
这段代码用于生成随机的手机号码,它从一个固定的号码池中选择一个前缀,然后结合当前时间戳的后两位形成一个唯一的手机号。此外,还打印了完整的时间戳以展示其随机性。
631

被折叠的 条评论
为什么被折叠?



