如何控制python writerow 不用每次打开csv文件
发布网友
发布时间:2022-06-02 21:17
我来回答
共1个回答
热心网友
时间:2023-10-03 06:38
代码
with open("C:\\Users\\XXX\\Desktop\\redis_log2.csv","w") as datacsv:
csvwriter = csv.writer(datacsv,dialect=("excel"))
csvwriter.writerow(["time","us","sy","cl","bcl","mem","rss","keys","cmd/s","exp/s","evt/s","hit%/s","hit/s","mis/s","aofcs"])
for info in parsecsv:
csvwriter.writerow([info["time"],info["us"],info["sy"],info["cl"],info["bcl"],info["mem"],info["rss"],info["keys"],info["cmd/s"],\
info["exp/s"],info["evt/s"],info["hit%/s"],info["hit/s"],info["mis/s"],info["aofcs"]])