复制python程序时去掉行号和多余的空格

# incoding=gbk

"""复制python程序时去掉行号和多余的空格"""

file_path = r'new.txt'
file_new_path = r'new_1.txt'
with open(file_path) as f_obj:
    lines = f_obj.readlines()

with open(file_new_path, 'w') as f_obj:
    i = 1
    for line in lines:
        if 11 <= i <= 83:
            line = line.replace(line[:3], '')
            print(line)
        f_obj.write(line)
        i += 1

 

posted @ 2020-10-17 09:53  tzg_雨中人  阅读(175)  评论(0)    收藏  举报