似乎您无法直接编辑python文件,所以这是我的建议:
# first get all lines from filewith open('file.txt', 'r') as f: lines = f.readlines()# remove spaceslines = [line.replace(' ', '') for line in lines]# finally, write lines in the filewith open('file.txt', 'w') as f: f.writelines(lines)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)