Python 实现手机号码补全
2022-02-08 16:12
对前三后四格式手机号进行枚举补全并生成文本文件。
a = input('请输入前三位:')
b = input('请输入后四位:')
n = input('补全后文件名:') + '.txt'
p = input('单列1/双列2')
if p==1:
f = open(n,"w")
for c in range (10):
c = str(c)
for d in range(10):
d = str(d)
for e in range(10):
e = str(e)
for g in range(10):
g = str(g)
f.write(a+c+d+e+g+b+'\n') # 将字符串写入文件中
f.close() # 关闭文件
else:
f = open(n, "w")
for c in range(10):
c = str(c)
for d in range(10):
d = str(d)
for e in range(10):
e = str(e)
for g in range(10):
g = str(g)
f.write(a + c + d + e + g + b +' '+a + c + d + e + g + b + '\n') # 将字符串写入文件中
f.close() # 关闭文件
本文来自博客园,作者:Haibara-Z3r0,转载请注明原文链接:https://www.cnblogs.com/Yu-0/articles/16337677.html