python : 对齐查询结果

python : align query result

如何让查询结果的所有值居中对齐?

print('\n\nThis is my first Query in Python\n')
print(tabulate(cursor, showindex=False, headers=cursor.columns))

这是结果:

enter image description here

使用 numalign 参数,像这样:

print('\n\nThis is my first Query in Python\n')
print(tabulate(cursor, showindex=False, headers=cursor.columns, numalign='center'))

刚才有人问过同样的问题:Pretty Printing a pandas dataframe 我会建议你,看看最后的答案,也只是试试你的制表功能:tablefmt='psql'