2013-07-29 50 views

回答

2

像這樣的事情?

from sys import stdout 
from time import sleep 

def show(word): 
    for char in word: 
    stdout.write(char) 
    stdout.flush() 
    sleep(1) 
    for char in word: 
    stdout.write('\b \b') 
    stdout.flush() 
    sleep(1) 

show('hello') 
2
os.system('clear') 

適用於linux。

你必須補充:

import os 

和Windows:

os.system('CLS') 
0

隨着subprocess是很容易的,你只需要做到這一點:

import subprocess 
try: 
    subprocess.call('clear') 
except: 
    subprocess.call('cls') 
+0

得到這個錯誤:'WindowsError:[錯誤2]' – Jovito

+0

看到我更新的答案和速度全面回溯請:d –

相關問題