python随机生成11位手机号码 文心快码BaiduComate 为了随机生成11位手机号码,我们可以按照以下步骤进行: 导入Python的random库: python import random 定义一个以1开头的字符串,包含手机号码的前缀: 手机号码通常以1开头,第二位通常是3、4、5、7、8中的一个,因此我们可以定义一个包含这些前缀的列表。 使用random...
random.seed(42)print(random.sample(range(20),k=10))st=random.getstate()# 取出生成上一行代码后,random的状态print(random.sample(range(20),k=20))# print 20random.setstate(st)# 恢复上一次的随机状态print(random.sample(range(20),k=10))# print same first 10# output:# [12, 0, 4, 3,...