Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
清除python中以前的终端输出_Python - Fatal编程技术网

清除python中以前的终端输出

清除python中以前的终端输出,python,Python,有没有办法清除终端以前的输出?如果是,怎么做?下面是一个代码示例 print "Hello..." #Code that clears previous terminal output print "All cleared!" 我知道移动应用程序pythonista有一个iOS模块可以做到这一点,但我想知道如何在Linux上做到这一点。根据您是在Windows还是Linux上,您可以做到: import os os.system('cls') #Windows os.system('cle

有没有办法清除终端以前的输出?如果是,怎么做?下面是一个代码示例

print "Hello..."
#Code that clears previous terminal output
print "All cleared!"

我知道移动应用程序pythonista有一个iOS模块可以做到这一点,但我想知道如何在Linux上做到这一点。

根据您是在Windows还是Linux上,您可以做到:

import os
os.system('cls')   #Windows
os.system('clear') #Linux
例如:

print 'Hello...'
os.system('clear') #or os.system('cls') for Windows
print "All cleared!"

@那个不好的代码员有什么意义?答案已经在这里给出了@TheNotGoodAtCodeGuy为什么你不能点击链接并在那里阅读答案?