file.txt:
1GmSluQ
owhMb7k
QD8wStm
o1ASe8x
muPoYv9
7vUqAIX
26OEwAz
imSVgHR
p08TrGf
dIL9Xpy
JfM49gr
CXgny8Q
GaRPvXS
blNvmrp
zrID2Wh
zWmfP1c
bPw6yYU
PnDTMac
idlDgHC
lLO6Bev
egl7Hnx
G1bacTQ
xi7GOlt
fgeqYbP
WATwhPG
dbQM9uV
HJqZeh4
nU6Q3bk
et6Odij
xZ93fv7
6Xkn4iv
Fjhdszu
q4oZcWn
o58MZB6
1DvVOc8
2Inx0lc
XYROn5W
e7nKGgp
BcrGSJR
ET9uAdz
IxcSKZ8
3VcdoJ9
VBYNhKt
1DkAnaG
w6WarX1
82Vgt0m
eMrQhUA
uxNwTZm
Im2KefJ
aVkexK2
7LPOphv
eLF93DE
9VG7IXy
Xq5mURw
rO7R526
dcOt9uo
fMsaDyW
5epdhwA
ARKnFWc
Re3V9qd
hK9pXto
TWwzyta
c4umDOo
n27Khmz
GCQuW5w
KWPcNdC
xv9Tz2L
l6ou8y7
KItcVba
xqFVz9H
5CS1R0s
9XyaPQ0
uzsXafg
PY6Jf0l
1tsZ7Iy
zbEns8N
1sJR5Za
t1YmLI3
wi6La1S
N7J6kcO
jkFDV4r
8IERJS5
K3f4NxV
NWMZF7t
1ozmZjT
z3yW5Ra
4XRYauq
8l9UYOD
owgOvNI
ag2hEQ7
scgTC1z
uGArQgc
SyNpv8w
BnbmNDW
UQMZpj2
jpFBRNv
UsbfMjR
qaXhPy6
H2fj3LY
代码:
import os
with open('email.txt',encoding='utf-8') as fr,open('.txt','w',encoding='utf-8') as fw:
for line in fr:
line=line.lstrip()
if not line[0].isdigit():
line=line.replace('\n',"@163.com\n")
fw.write(line)
os.remove('email.txt')
os.rename('.txt','email.txt')
来源:oschina
链接:https://my.oschina.net/u/4417289/blog/3878613