os.system('cls') 不清除 Pycharm 中的屏幕? [英] os.system('cls') doesn't clear the screen in Pycharm?

查看:345
本文介绍了os.system('cls') 不清除 Pycharm 中的屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Pycharm 中使用 os.system('cls') 来清除之前打印过的屏幕.但是,在运行代码时,它不会清除以前打印的内容,而是在末尾打印一个向上的箭头.可能是什么问题?

I use os.system('cls') in Pycharm to clear the screen from what has been printed before. However, when running the code, it does not clear the formerly printed stuff, and instead prints an upward arrow at the end. What can the problem be?

推荐答案

PyCharm 对 Windows 系统控制台的模拟不是 100%.也不是任何IDE.在 IDLE 或 PythonWin 中尝试一下,您会发现它还会执行一些您在 Windows 控制台中不期望的操作.

PyCharm's emulation of the Windows system console isn't 100%. Neither is any IDE's. Try that in IDLE or PythonWin, and you will see that it also does something other than you might expect from the Windows console.

这种行为是设计使然.请记住,大多数现实世界的 Python 交互式应用程序不会通过 input()print() 调用与用户交互.

This behaviour is by design. Bear in mind that most real-world Python interactive applications do not interact with their users via input() and print() calls.

如果您希望输出的行为与 Windows 控制台完全一样,请将输出发送到 Windows 控制台.

If you want your output to behave exactly like the Windows console then send your output to the Windows console.

这篇关于os.system('cls') 不清除 Pycharm 中的屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆