WebLinuxStudy

导航

 

逐行读取txt文件

path = r'D:\123456\1.txt'
with open(path, 'r', encoding='utf-8') as f:
    for line in f:
        value = line[:-1] #去掉换行符
        print(value)

 

posted on 2019-08-29 16:18  WebLinuxStudy  阅读(5944)  评论(0编辑  收藏  举报