您的位置:首页 > 编程语言 > Python开发

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

2014-09-12 15:59 169 查看
举个例子:

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()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: