gpt4 book ai didi

python - 将两个变量添加到 QComboBox

转载 作者:行者123 更新时间:2023-12-01 08:47:38 25 4
gpt4 key购买 nike

这是我的代码片段:

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')

如何获得所需的输出:名字姓氏

最佳答案

使用连接:

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

或更好:

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

关于python - 将两个变量添加到 QComboBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53243543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com