导入csv
reader = csv.reader(post.text,quotechar ="'")
打开(' source91.csv',' wb')为f:
writer = csv.writer(f)
writer.writerows(list(reader))
输出垂直显示我需要以CSV格式水平打印数据
答案 0 :(得分:0)
简单回答:如果您只有一个数组
with open('source91.csv', 'wb') as f:
writer = csv.writer(f, delimiter='\n')
writer.writerows(list(reader))
复杂的答案:
您可能需要numpy
来实现。
transpose
只会将行转换为列
import numpy as np
a = np.array(list(reader))
a = np.append(a, list(reader)) # if you have multiple lines
a = np.transpose(a)
np.savetxt('source91.csv', a)