1.cxfreeze使用pip安装,报错host,解决方法:关闭蓝灯vpn,即使没有连接
2.安装完成后,创建setup.py,个人用例:
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
build_options = {'packages': [], 'excludes': []}
base = 'Console'
executables = [
Executable('C:\\Users\\23679\\Desktop\\python\\hello world.py', base=base, target_name = 'hello world.py')
]
setup(name='hh',
version = '1.0',
description = 'good',
options = {'build_exe': build_options},
executables = executables)
python cx_setup.py build
3.打包后的exe按回车就会退出,一种解决方法:
末尾加一行等待输入防止跳出,例子:
input("press enter to exit")
4.py4e遇到的注意点:
4.1
int取整,直接砍掉小数部分
round取整,四舍五入
4.2
range(5),0-4不包括5 ==range(0,5)==range(0,5,1)
range(0,-10,-2)
0,-2,-4,-6,-8 #不包括-10