0

我只是想知道是否有办法让列表中的每个元素显示在单独的行上,或者在 TKinter 的文本框中在它们之间添加一行。我现在拥有的是从另一个文件中提取的简单代码,但我不确定如何去做。

我的代码是这样的:

gui = compare.GCCCOMPARE.compare(mygcccompare)

root = Tk()
text = Text(root)
text.insert(INSERT,  gui)
text.pack() 
root.mainloop()

清单在哪里gui

我在文本框中得到的是:

["Parameter Change between files 0 and 1 :  {'LPSUM': [(233, 42), '(253, 196)']}", "Parameter Change between files 1 and 2 :  {'LPSUM': [(253, 196), '(15, 194)']}", "Parameter Change between files 2 and 3 :  {'LPSUM': [(15, 194), '(229, 92)'],}"]

但我想要的是:

["Parameter Change between files 0 and 1 :  {'LPSUM': [(233, 42), '(253, 196)']}", 

"Parameter Change between files 1 and 2 :  {'LPSUM': [(253, 196), '(15, 194)']}", 

"Parameter Change between files 2 and 3 :  {'LPSUM': [(15, 194), '(229, 92)']}"]
4

1 回答 1

2
("\n".join(map(str, listname)))

这就是我一直在寻找的。如果有人在格式化列表以使每个元素都在新行上似乎有这样的问题,那么此代码将为您工作

于 2013-10-03T14:33:29.387 回答