ssh框架做的网站问题,天津网站优化步骤,电子商务网站计划书,wordpress侧栏弹窗登录打包工具
pyinstaller
安装pyinstaller
如果你的网络稳定#xff0c;通常直接使用下面的命令安装即可#xff1a;
pip install pyinstaller
当然了#xff0c;你也可以下载pyinstaller源码包#xff0c;然后进入包目录执行下面的命令#xff0c;同样可以安装#xff…打包工具
pyinstaller
安装pyinstaller
如果你的网络稳定通常直接使用下面的命令安装即可
pip install pyinstaller
当然了你也可以下载pyinstaller源码包然后进入包目录执行下面的命令同样可以安装前提是需要安装setuptools
python setup.py install 检查pyinstaller安装成功与否
只需要执行如下命令其中一个即可
pyinstaller --version
pyinstaller -v pyinstaller参数作用
-F 表示生成单个可执行文件-D –onedir 创建一个目录包含exe文件但会依赖很多文件默认选项-w 表示去掉控制台窗口这在GUI界面时非常有用。不过如果是命令行程序的话那就把这个选项删除吧-c –console, –nowindowed 使用控制台无界面(默认)-p 表示你自己自定义需要加载的类路径一般情况下用不到-i 表示可执行文件的图标其他参数可以通过pyinstaller --help查看
开始打包
进入python需要打包的脚本所在目录然后执行下面的命令即可
pyinstaller -F -i favicon.ico xxx.py 打包结果
打包完成后进入到当前目录下会发现多了__pycache__、build、dist、nhdz.spec这四个文件夹或者文件其中打包好的exe应用在dist目录下面进入即可看到可以把他拷贝到其他地方直接使用如下图所示是打包完成后的目录 执行exe应用
因为是exe应用是可执行文件了所以直接双击运行即可运行效果如下图所示 到这里exe文件就已经生算是打包完成并且可以运行了如果你想在其他平台运行只需要拷贝dist下面的文件即可
ICO图标制作
前面需要用到ICO图标大家可以网上搜索“ICO 在线生成”可以直接点击ICO图标制作在上面制作、然后保存也行 测试程序源码
# -*- coding: utf-8 -*-
# Time : 2019/07/14 19:47
# Author : Liu
# File : exe.pyimport random
import timedef enter_stake(current_money):输入小于结余的赌资及翻倍率,未考虑输入type错误的情况stake int(input(How much you wanna bet?(such as 1000):))rate int(input(What multiplier do you want?你想翻几倍(such as 2):))small_compare current_money stake * ratewhile small_compare True:stake int(input(You has not so much money ${}!How much you wanna bet?(such as 1000):.format(stake * rate)))rate int(input(What multiplier do you want?你想翻几倍(such as 2):))small_compare current_money stake * ratereturn stake,ratedef roll_dice(times 3):摇骰子print( Roll The Dice! )points_list []while times 0:number random.randrange(1,7)points_list.append(number)times - 1return points_listdef roll_result(total):判断是大是小is_big 11 total 18is_small 3 total 10if is_small:return Smallelif is_big:return Bigdef settlement(boo,points_list,current_money,stake 1000,rate 1):结余increase stake * rateif boo:current_money increaseprint(The points are str(points_list) .You win!)print(You gained $ str(increase) .You have $ str(current_money) now. )else:current_money - increaseprint(The points are str(points_list) .You lose!)print(You lost $ str(increase) .You have $ str(current_money) now. )return current_moneydef sleep_second(seconds1):休眠time.sleep(seconds)# 开始游戏
def start_game():开始猜大小的游戏current_money 1000print(You have ${} now..format(current_money))sleep_second()while current_money 0:print( Game Starts! )your_choice input(Big or Small: )choices [Big,Small]if your_choice in choices:stake,rate enter_stake(current_money)points_list roll_dice()total sum(points_list)actual_result roll_result(total)boo your_choice actual_resultcurrent_money settlement(boo,points_list,current_money,stake,rate)else:print(Invalid input!)else:sleep_second()print(Game Over!)sleep_second(2)if __name__ __main__:start_game()