简体   繁体   中英

Clear python shell within script

I am trying to create a utility program, but after the user types in the passcode and goes to the main menu, the passcode is still there and is show right above it. I asked this question before, but users gave me a command instead of something the script does for you. I was wondering if there is something I can type into my script that can clear the python shell without having to directly type it into the shell.

您应该使用getpass读取密码而不回显密码,这是安全读取密码的推荐方式。

If you are using Linux:

import os
os.system("clear")

if you are using windows:

import os
os.system('CLS')

Note: you should really not do something like this with passcodes for security reasons, but this does clear the shell

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM