在 stdout 中打印从底部开始的第 3 行
Print 3rd line from the bottom in stdout
目前我是运行这个
while p.poll() is None:
output = p.stdout.readline()
print output,
发生的情况是所有行都在打印。我正在寻找的是打印,通常是从底部开始的 第 3 行 ,其中包含有关命令是否已正确执行的数据。
另外有没有办法像底部的状态栏那样使用 Tkinter Label[=11= 实时更新]
解决方案,感谢@TadhgMcDonald-Jensen 的提示
在终端中仅打印倒数第三行(索引 -3)shell window
import Tkinter as *
import subprocess
out = [] # Create empty list
for line in iter(p.stdout.readline, ''):
out.append(line.rstrip('\n')) # append list
print out[-3] # print item in the list, in this case -3
或者在tkinter标签中显示
import Tkinter as *
import subprocess
out = [] # Create empty list
for line in iter(p.stdout.readline, ''):
out.append(line.rstrip('\n')) # append list
window = Tk()
Label(window, text=out[-3]).grid(sticky=W)
目前我是运行这个
while p.poll() is None:
output = p.stdout.readline()
print output,
发生的情况是所有行都在打印。我正在寻找的是打印,通常是从底部开始的 第 3 行 ,其中包含有关命令是否已正确执行的数据。
另外有没有办法像底部的状态栏那样使用 Tkinter Label[=11= 实时更新]
解决方案,感谢@TadhgMcDonald-Jensen 的提示
在终端中仅打印倒数第三行(索引 -3)shell window
import Tkinter as *
import subprocess
out = [] # Create empty list
for line in iter(p.stdout.readline, ''):
out.append(line.rstrip('\n')) # append list
print out[-3] # print item in the list, in this case -3
或者在tkinter标签中显示
import Tkinter as *
import subprocess
out = [] # Create empty list
for line in iter(p.stdout.readline, ''):
out.append(line.rstrip('\n')) # append list
window = Tk()
Label(window, text=out[-3]).grid(sticky=W)