写一个随机产生138开头手机号的程序
1、输入一个数量,产生xx条手机号
prefix = \'138\'
2、产生的这些手机号不能重复
import random
import string
count = input("请输入要生成的手机号个数:")
if count.isdigit():
phonelist = []
for i in range(int(count)):
prefix = \'138\'
phone = prefix + \'\'.join(random.sample(string.digits,9))
if phone not in phonelist:
phonelist.append(phone)
print("手机号:",phonelist)
else:
print("手机号重复")
else:
print("请输入正确的个数")