龙空技术网

利用PYTHON替换CSV文件内的部分字符

kkh123 90

前言:

眼前同学们对“python123字符替换”都比较讲究,兄弟们都需要学习一些“python123字符替换”的相关知识。那么小编同时在网络上收集了一些关于“python123字符替换””的相关文章,希望朋友们能喜欢,同学们快快来学习一下吧!

```

#coding:utf-8

import os

import os.path

csvpath=os.getcwd()+"\\" #文件所在路径

f=open('./kqi.csv',encoding="gbk") ##文件1,KQI.CSV表

g=open('./mos.csv',encoding="gbk") ##文件2,mos.CSV表

content = f.read()

conten1 = g.read()

f.close()

g.close()

t = content.replace("=","") #kqi.csv中=号替换为空

t1=conten1.replace("=","") #mos.csv中=号替换为空

with open("kqi_new.CSV","w",encoding='gbk') as f1: #读取并写入新的kqi_new.CSV表

f1.write(t)

with open("mos_new.CSV","w",encoding='gbk') as f2:#读取并写入新的mos_new.CSV表

f2.write(t1)

标签: #python123字符替换