问题
I need to create a message box in python without using python Tkinter library so that I can use that before using exit()
function this will display the message and answer as soon as user presses okay, user gets out of program.
回答1:
Here's one way to do it with Windows' msg
command. The code is based on @ErykSun's comment under the question Can't execute msg (and other) Windows commands via subprocess.
import os
import subprocess
sysroot = os.environ['SystemRoot']
sysnative = (os.path.join(sysroot, 'SysNative')
if os.path.exists(os.path.join(sysroot, 'SysNative'))
else
os.path.join(sysroot, 'System32'))
msgexe_path = os.path.join(sysnative, 'msg.exe')
subprocess.run([msgexe_path, '*', 'ALL YOUR BASE ARE WHERE BELONG TO US.'])
来源:https://stackoverflow.com/questions/59704480/how-to-create-an-alert-box-without-using-tkinter