python处理txt文件的一种情况

在txt文本中,以换行符作为标记分段处理txt文件中的内容的方法:

with open(path, 'r', encoding='utf-8') as f:
    for line in f:
        if line!='\n':
            print(line,end='')
        else:
            break
View Code

猜你喜欢

转载自www.cnblogs.com/yibeimingyue/p/10051286.html