【问题标题】:Adding two variables to a QComboBox将两个变量添加到 QComboBox
【发布时间】:2019-04-14 01:47:57
【问题描述】:

这是我的代码 sn-p:

self.cursor.execute("MATCH (n:Person) RETURN n.firstname, n.lastname")
for i in self.cursor:
    self.cbPerson.addItem(str(i[0])

这给了我一个名字列表。

self.cbPerson.addItem(str(i[0:3])

这给了我名字和姓氏,但像这样('firstname','lastname')

如何获得所需的输出:firstname lastname

【问题讨论】:

    标签: python python-3.x pyqt pyqt5 qcombobox


    【解决方案1】:

    使用连接:

    for i in self.cursor:
        self.cbPerson.addItem(" ".join(i))
    

    或更好:

    self.cbPerson.addItems([" ".join(i) for i in self.cursor])
    

    【讨论】:

      猜你喜欢
      • 2021-04-12
      • 2017-10-24
      • 1970-01-01
      • 1970-01-01
      • 2022-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-20
      相关资源
      最近更新 更多