filename = ('E:/demo/demo.py')
with open(filename,'r')as fp:#赋值到fp上
lines = fp.readlines()
maxLength = len(max(lines,key=len))# 找到最大长度
line = [line.rstrip().ljust(maxLength)+'#'+str(index)+'\n'
for index,line in enumerate(lines)] #开始编号
with open(filename[:-3]+'_new.py','w')as fp:
fp.writelines(lines)
05-22
04-13
09-01