我正在使用一种工具将我的 python 文件转换为 .exe 文件。您可以在此视频中找到该工具py to .exe。
现在,当我转换此代码时,一切正常:
width = float(input("Enter the width: "))
height = float(input("Enter the height: "))
area = width * height
print("The area is", area, "square units.")
Run Code Online (Sandbox Code Playgroud)
但是每当我在其中添加一行带有 PyAutoGUI 模块的代码时,.exe 文件就会立即关闭并且什么也不做。
例子:
width = float(input("Enter the width: "))
pyautogui.moveTo(492, 106, 0.2)
height = float(input("Enter the height: "))
area = width * height
print("The area is", area, "square units.")
Run Code Online (Sandbox Code Playgroud)
如何防止 .exe 文件关闭以及为什么不执行 PyAutoGUI 代码?