如何删除行首空格 with open(“train01.txt”,‘r’) as fr,open(“train02.txt”,‘w’) as fw: for line in fr.readlines(): fw.write(line.lstrip())