import os
import sys
filename = '4.111.txt'
fo = open('outfile.txt', 'w')
cnts = open(filename).readlines()
for cnt in cnts:
cnt = cnt.strip()
if cnt.endswith(','):
cnt = cnt[:-1]
fo.write(cnt + '\n')
fo.close()
Python 代码。 保存成 py文件,放到 4.111.txt 同一目录下执行即可。
# -*- coding: utf-8 -*-
with open('4.111.new.txt', 'w') as fp:
for line in open('4.111.txt'):
fp.write(line.strip().strip(',')+"\n")
4.111.new.txt是去掉逗号的文件
如果解决了您的问题请采纳!
如果未解决请继续追问