逐行读取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)

 

相关文章:

  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2021-12-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
相关资源
相似解决方案