【发布时间】:2019-12-12 04:38:37
【问题描述】:
我在清除 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。
【问题讨论】:
-
这是在什么操作系统上运行的?
-
这是我第一次使用 os,所以我不太清楚,但我在 python 3.8 中使用它。 @gdanton
-
如果是windows你必须使用'cls'
-
@gdanton 我正在使用 MacOs
-
代码中的
os.system('clear')永远不会被执行,因为return input('\nEnter your responce: ')就在它退出函数之前。
标签: python python-3.x macos printing console