用python处理含身份证号码的文本文件,将其另外保存为csv文件,该csv文件使用wps打开显示身份证号码后面三位数变为0,解决的办法是:身份证号码前加'\t'
,例如下面代码:
origine_file = r"C:\Files\名单.txt"
save_to = "C:\Files\save.csv"
f = open(save_to,'w+',encoding='utf-8')
for line in open(origine_file,encoding='utf-8'):
content = line.split(sep=',')
print(content[0],content[1],content[2])
f.write(content[0])
f.write(',')
f.write(content[1])
f.write(',')
f.write('\t'+content[2])
f.write('\n')
f.close()
参考链接
[1]https://blog.youkuaiyun.com/tz_gx/article/details/51678810