这是我用来将数据写入.csv文件的代码。with open('temp.csv', 'a') as fp:
a = csv.writer(fp, delimiter='\t')
data = [['faceXpos','faceYpos','faceHeight','faceWidth','imageViewHeight','imageViewWidth','tshirtXpos', 'tshirtYpos','tshirtWidth','tshirtHeight'],
[faceXpos, faceYpos, faceHeight, faceWidth, imageViewHeight, imageViewWidth, tshirtXpos, tshirtYpos, tshirtWidth, tshirtHeight]]
a.writerows(data)
输出如下:faceXpos faceYpos faceHeight faceWidth imageViewHeight imageViewWidth tshirtXpos tshirtYpos tshirtWidth tshirtHeight
118 432 84 84 568 320 13.0 136 294.0 346.0
faceXpos faceYpos faceHeight faceWidth imageViewHeight imageViewWidth tshirtXpos tshirtYpos tshirtWidth tshirtHeight
117.4 433.81 82.35999 82.36 568 320 14.45 134.19 288.26 340.09
如何对齐它,使每列下的数据以更易于读取的方式完全对齐?期望输出:(即使数据位于列的中心也可以)faceXpos faceYpos faceHeight faceWidth imageViewHeight imageViewWidth tshirtXpos tshirtYpos tshirtWidth tshirtHeight
118 432 84 84 568 320 13.0 136 294.0 346.0