好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Python在window平台打包工具pyinstaller

Java 一次编译到处运行,Python没有这么好本事,但是也有一个pyinstaller可以打包exe,在window平台下运行

pyinstaller

安装pip install pyinstaller

参数

计算机小助手例子

在我桌面有demo8.py文件,psutil这个标准库是计算计算机的性能的。

 # -*- coding:utf-8 -*-
# time :2019/3/28 22:44
# author: Runsen
print('欢迎您,我是您的计算机小助手')
import psutil as ps
import time
print('本机开机的时间是:{}'.format(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(ps.boot_time()))))
print("-------------------------")
print("CPU部分")
print("-------------------------")
print('本机物理CPU个数:{}个'.format(ps.cpu_count()))
print('本机逻辑CPU个数:{}个'.format(ps.cpu_count(logical=False)))
print("-------------------------")
print('内容部分')
print("-------------------------")
print('本机内存大小为:{}个字节'.format(ps. Virtual _memory().total))
print('本机已用内存大小为:{}个字节'.format(ps. Virtual _memory().used))
print('本机已用内存大小占比为:{}%'.format(ps. Virtual _memory().percent))
input() 

注意点:

一定要在代码最后面加上input(),这样打开exe不会一散而过,

cd 到代码的目录执行 pyinstaller -F demo8.py 这样就会生成日记等文件

我们找到exe

双击打开它,这样就显示出电脑的内存占用,说明下电脑的内存和你下载的东西无关,就是看你打开了多少网页和程序。

和jar包比起来就是给人家完爆的感觉。 赞 赏 作 者

一个“软实力”,“硬技术”同步成长的公众号

查看更多关于Python在window平台打包工具pyinstaller的详细内容...

  阅读:37次