首页 > 编程语言 > 详细

python将文件写成csv文件保存到本地

时间:2014-09-12 16:51:53      阅读:399      评论:0      收藏:0      [点我收藏+]

举个例子:

import csv
import os

path=/tmp/
file=test.csv
def generate_csv(path,file):
    if not os.path.exists(path):
        os.mkdir(path)
    files=os.path.join(path,file)
    # os.system(‘touch %s‘ %files)
    with open(files,w) as f:
        writer=csv.writer(f)
        writer.writerow([client_name,os..,path])
    return files

def main():
    generate_csv(path,file)

if __name__==__main__:
    main()

 

python将文件写成csv文件保存到本地

原文:http://www.cnblogs.com/alexkn/p/3968554.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!