2012-02-28 16 views
2

我想編寫一個程序,它將每秒鐘打印一個字符串,另一方面它將允許用戶編寫文本,我在下面的代碼片段。我的問題是每次打印新行時,輸入行也受到干擾。有沒有辦法將輸入線與輸入線分開?不斷使用python多線程獲取輸入

import time 
from thread import start_new_thread 

def heron(): 
    while 1: 
    time.sleep(1) 
    print "some text" 

start_new_thread(heron,()) 
c = raw_input("Enter text>") 

回答

1

我懷疑你可以這樣做,沒有curses。可能有另一種方式,但我認爲它不會很漂亮。有一個基本的方法here