Step 1: 编写mysetup.py
import py2exe
#mysetup.py
from distutils.core import setup
import py2exe
setup(console=['Hello.py'])
其中Hello.py就是想打包的Python脚本
Step 2: 将该mysetup.py和Hello.py放在同一个目录下
Step 3: 打开cmd,cd进入Step 2中的路径,运行python mysetup.py py2exe
大功告成,你会发现多出一个dist文件夹,里面包含了你想要的.exe文件,同时也会编译其他需要的文件