python3把txt文件转换为csv文件

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import csv
with open('file.csv','a',newline='') as csvfile:
spamwriter = csv.writer(csvfile, dialect='excel')

with open('data_2016_1.txt', 'rb') as filein:
for line in filein:
line_list = line.decode().split('\t')
spamwriter.writerow(line_list)

上一篇:Mac下查看已安装的jdk版本及其安装目录


下一篇:ubuntu 14.04 安装jdk 1.8