【问题标题】:Format input dictionary string as columns将输入字典字符串格式化为列
【发布时间】:2020-08-13 20:28:23
【问题描述】:

我正在使用 concat 函数将几个数据库字段转换为 Tkinter Combobox。

Data:
first_name  last_name       city        state   ID
John        Smith           Dallas      TX      1
Richard     Cunningham      Ft. Worth   TX      2
'''
        SELECT concat (first_name,' ',last_name,' ', city,', ',state,' '),ID
'''
Results:
{'John Smith Dallas, TX':1, 'Richard Cunningham Ft. Worth, TX' :2 }

我想做的是格式化字符串,例如,Smith 将采用与 Cunningham 相同数量的字符。然后,当我将数据放入 cb 时,它会显示为列。

感谢您的帮助。

【问题讨论】:

    标签: python


    【解决方案1】:

    一个好的解决方案是创建一个表而不是一个 cb。对此的解决方案/描述显示为Here (stackoverflow - does tkinter have a table widget)

    否则,您可以利用诸如texttableasciitable 之类的库(或那里的逻辑)来适当地格式化您的文本。一般asciitable的解决方案可以找到here - (stackoverflow - How can I pretty print ascii tables)

    【讨论】:

      猜你喜欢
      • 2019-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-06
      • 2021-08-21
      • 1970-01-01
      相关资源
      最近更新 更多