【问题标题】:python : align query resultpython:对齐查询结果
【发布时间】:2018-08-06 18:33:07
【问题描述】:

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

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

这是结果:

enter image description here

【问题讨论】:

  • tabulate() 使用numalign= 和/或stralign= 命名参数。例如。 tabulate(cursor, showindex=False, headers=cursor.columns, numalign="center")

标签: python pandas pyodbc


【解决方案1】:

使用numalign 参数,像这样:

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

【讨论】:

    【解决方案2】:

    不久前有人问过同样的问题:Pretty Printing a pandas dataframe 我会建议你看看最后一个答案,也可以试试你的制表功能:tablefmt='psql'

    【讨论】:

      猜你喜欢
      • 2019-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-22
      • 1970-01-01
      • 2020-03-26
      相关资源
      最近更新 更多