Make a string output as a list in Pwm

How can I make a string output a list? (Probably very simple, I know)

I have looked through all of google, and NONE of the solutions worked.

My code: (it's a bit paraphrased)

import Pmw
from tkinter import *

root = Tk()

console = Pmw.ScrolledText(...some arguments...)
console.pack(...some arguments...)

console.settext(os.listdir("."))

root.mainloop()

Outputs: file1.txt file2.txt file3.txt in the Pmw.ScrolledText box.

What do I need to do to make the output look like the following?

file1.txt
file2.txt
file3.txt

My thanks to you.


使用换行符加入os.listdir()返回的list的项目:

filenames = os.listdir('.')
text = 'n'.join(filenames)
console.settext(text)

You can use n (new line character). for example: print 'file1.txtnfile2.txtnfile3.txt'

You can find more information here - https://docs.python.org/2/tutorial/inputoutput.html

链接地址: http://www.djcxy.com/p/88348.html

上一篇: 如何在MKAnnotations上显示MKOverlay?

下一篇: 在Pwm中以列表形式输出字符串