import csvfrom StringIO import StringIOrows = list(csv.reader(StringIO( '''value1,somevalue2,value3,reallylongvalue4,value5,superlongvalue6value1,value2,reallylongvalue3,value4,value5,somevalue6''')))widths = [max(len(row[i]) for row in rows) for i in range(len(rows[0]))]for row in rows: print(' | '.join(cell.ljust(width) for cell, width in zip(row, widths)))
输出:
value1 | somevalue2 | value3| reallylongvalue4 | value5 | superlongvalue6value1 | value2 | reallylongvalue3 | value4| value5 | somevalue6
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)