如何在 python 中的变量之间使用制表符来创建包含 3 列的单行?
how can i use tabs between variables in python to create a single row with 3 columns?
这基本上是我要打印的变量:
print n, bu, qui
现在我是这样的:
print n"\t", int(bu.total_seconds() * 1000)"\t", int(qui.total_seconds() * 1000)"\t"
使用str.format
:
print "{}\t{}\t{}".format(n, int(bu.total_seconds() * 1000),int(qui.total_seconds() * 1000))
您可以使用多种不同的方式来调整格式 str.format's Format Specification Mini-Language
这基本上是我要打印的变量:
print n, bu, qui
现在我是这样的:
print n"\t", int(bu.total_seconds() * 1000)"\t", int(qui.total_seconds() * 1000)"\t"
使用str.format
:
print "{}\t{}\t{}".format(n, int(bu.total_seconds() * 1000),int(qui.total_seconds() * 1000))
您可以使用多种不同的方式来调整格式 str.format's Format Specification Mini-Language