赞
踩
python读写txt和json文件
1、往txt文件中写入内容
- # write txt
- import os
-
- name =['a','b','c','d']
- seq=['11111','22222','33333','44444']
-
- output_dir = '/home/cqh/faceData'
- emb_filename = os.path.join(output_dir, 'emb_txt.txt')
-
- with open(emb_filename, "w") as f:
- for i in range(0, len(name)):
- f.write(name[i] + "\t" + seq[i] + "\n")
- f.close()
运行结果如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。