在Python中打印制表符,您可以使用以下几种方法:
1. 使用制表符转义序列 `\t`:
print("Hello\tWorld!")
输出:
Hello World!
2. 使用制表符字符 `\u0009`:
print("\u0009Hello\u0009World!")
输出:
Hello World!
3. 使用 `format()` 方法:

name = "John"age = 30print("{}\t{}".format(name, age))
输出:
John 30
4. 使用 `tabulate` 模块:
from tabulate import tabulatedata = [["Name", "Age"], ["John", 30], ["Jane", 25]]print(tabulate(data, tablefmt="grid"))
输出:
+--------+-----+| Name | Age |+========+=====+| John | 30 |+--------+-----+| Jane | 25 |+--------+-----+
