1

在 Windows 平台上运行 Python 3.4。

当没有输入输入字段时,我想使用 ctypes 踢出错误消息框。代码是:

if len(pet) == 0:
   subprocess.call("Python help.py")
if pet == "cat":
    try:
        age = int(input("how old is your cat?"))
    except ValueError:
        print ("put in a number please")

Ctypes代码是:

import ctypes  
ctypes.windll.user32.MessageBoxW(0, "Enter data here please", "Input Error", 1) 

我的 Ctypes msgbox 完美打开,但我最终同时打开了一个 python.exe 窗口。此窗口在 msgbox 正常时关闭,但在屏幕上显示效果不佳。问题:如何让 msgbox 打开而不打开 python.exe 窗口?

4

0 回答 0