python - 如何清除打印的文本?
问题描述
我在 python 3.8 中清除文本时遇到问题。我看过类似的答案,但他们并没有帮助我解决我遇到的问题,因为这些答案提供的解决方案对我不起作用。这是代码行:
def userInstructions(userInput):
if userInput == "help" or userInput == "Help":
help()
elif userInput == "list" or userInput == "List":
words()
elif userInput == "tutorial" or userInput == "Tutorial":
tutorial()
elif userInput == "salve":
LatinRef.salve()
return input('\nEnter your responce: ')
os.system('clear')
我想要做的是每次用户输入响应时响应将被清除并且它将是空白而不是像这样出现:
Type in your command or any Latin word to review or learn.
Enter your responce: hello
Type in your command or any Latin word to review or learn.
Enter your response: help
我怎样才能解决这个问题?如果有帮助,我目前正在使用 python 3.8。
解决方案
按照https://stackoverflow.com/a/518007/1244045中的说明尝试此操作
clear = lambda: os.system('clear')
clear()
'cls' 用于 Windows。
推荐阅读
- wso2 - 在 Ballerina 中访问表数据结构时出现问题。错误无效操作...不支持非必填字段的字段访问
- ios - 无法在 Iphone 上模拟应用程序
- go - VSCode golang 模块只能在调试模式下工作 / 模块目录问题?
- python - 如何使变量等效于不同的变量
- php - 需要调整一个废弃的插件供我使用
- python - 如何在 Python 程序中读取(仅读取未设置).env 文件
- javascript - jQuery fadeOut 有效,fadeIn 没有错误,没有变化,同样,fadeToggle 不会回来
- ios - FirebaseCore - 词法或预处理器问题 - 找不到“GoogleUtilities/GULAppEnvironmentUtil.h”文件
- java - 我收到了来自 Play 商店的安全警报
- android - java.lang.ClassNotFoundException:找不到类“android.view.View$OnUnhandledKeyEventListener”