lines_maxlenth = 0
line_numbers = 1
code_in = open("demo.py","r").readlines()
code_out = open("demo_new.py", "w")
for i in code_in:
if(lines_maxlenth < len(i)):
lines_maxlenth = len(i)
for i in code_in:
i = i.ljust(lines_maxlenth+1).replace('\n','') + "#" + str(line_numbers) + "\n"
line_numbers += 1
code_out.write(i)
行号添加
最新推荐文章于 2024-08-25 21:53:43 发布