python处理csv文件列错位_使用Python将列名与CSV文件中的数据对齐

这是我用来将数据写入.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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值