python readlines 去除\n
时间: 2023-05-19 20:05:30 浏览: 95
烟花代码编程python满屏-05-读取函数之readlines.ev4.rar
可以使用strip()函数去除每行末尾的\n,代码如下:
with open('file.txt', 'r') as f:
lines = [line.strip() for line in f.readlines()]
阅读全文
烟花代码编程python满屏-05-读取函数之readlines.ev4.rar