f = open('a.txt', 'r')
content = f.readlines()
for i in range(0, len(content) - 1):
content[i] = content[i].strip('\n')
print(content)
f.close()
使用for循环去掉readlines()方法的\n
最新推荐文章于 2022-12-12 15:39:40 发布
f = open('a.txt', 'r')
content = f.readlines()
for i in range(0, len(content) - 1):
content[i] = content[i].strip('\n')
print(content)
f.close()