1,文本的平均列数
with open ('latex.log','r') as fo:
c = 0
r = 0
for line in fo:
line = line.replace("\n",'')
if line == '':
continue
c = c + len(line)
r = r + 1
print(round(c/r))
2,CSV格式清洗与转换
f = open("data.csv","r")
ls = f.readlines()
ls = ls[::-1]
lt = []
for item in ls:
item = item.strip("\n")
item = item.replace(" ", "")
lt = item.split(",")
lt = lt[::-1]
print(";".join(lt))
f.close()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)