当前位置: 首页 > wzjs >正文

织梦手机wap网站标签调用垂直网站

织梦手机wap网站标签调用,垂直网站,wordpress 网址 代码,wordpress打赏后插件目前python打包成exe的工具主要有:PyInstaller Briefcase py2exe py2app Nuitka CX_Freeze等。 不同于C代码,可以直接编译成可执行的exe文件,或者js代码在浏览器中就能执行,python代码必须通过python解释器来运行&#xff0c…

     目前python打包成exe的工具主要有:PyInstaller  Briefcase  py2exe  py2app  Nuitka  CX_Freeze等。

       不同于C++代码,可以直接编译成可执行的exe文件,或者js代码在浏览器中就能执行,python代码必须通过python解释器来运行,很多操作系统都没有预装。所以需要通过工具将python代码打包成可独立运行的exe文件,工具主要包括PyTnstaller  Briefcase  py2exe  py2app  Nuitka  CX_Freeze等,本期介绍打包工具Nuitka。

1.Pip install nuitka安装

2.nuitka yanhua.py打包

 3.执行exe程序 

        发现直接打包好的exe文件仍然不可以在没有安装python的电脑上执行

4.添加参数打包

        所以我们还得再打包时加上参数 --standalone,这样才会将python解释器和目标代码的所有依赖都打包进去,参数--onefile将所有文件打包成一个单独运行的可执行文件

 打包完成

一般默认的cl编译,也可以添加mingw编译。

打包可能出现以下情况,可能是微信开发者工具中ws2_32.dll导致的问题,直接卸载微信开发者工具就好了。

Nuitka对更复杂的GUI程序和第三方库支持情况

以下是一个示例代码

import tkinter as tk
from tkinter import ttk, messagebox, filedialog
import osclass MyApp:def __init__(self, root):self.root = rootself.root.title("功能演示程序")self.root.iconbitmap("C:/Users/Administrator/Desktop/z.ico")self.root.geometry("800x600")# 创建选项卡self.notebook = ttk.Notebook(root)self.notebook.pack(expand=True, fill='both', padx=5, pady=5)# 创建三个选项卡页面self.tab1 = ttk.Frame(self.notebook)self.tab2 = ttk.Frame(self.notebook)self.tab3 = ttk.Frame(self.notebook)self.notebook.add(self.tab1, text='文本处理')self.notebook.add(self.tab2, text='文件操作')self.notebook.add(self.tab3, text='计算工具')self.setup_text_tab()self.setup_file_tab()self.setup_calc_tab()# 创建状态栏self.status_bar = tk.Label(root, text="就绪", bd=1, relief=tk.SUNKEN, anchor=tk.W)self.status_bar.pack(side=tk.BOTTOM, fill=tk.X)def setup_text_tab(self):# 文本输入区域frame = ttk.LabelFrame(self.tab1, text="文本处理区域", padding=10)frame.pack(fill='both', expand=True, padx=5, pady=5)self.text_input = tk.Text(frame, height=10)self.text_input.pack(fill='both', expand=True, pady=5)btn_frame = ttk.Frame(frame)btn_frame.pack(fill='x', pady=5)ttk.Button(btn_frame, text="转大写", command=self.convert_upper).pack(side='left', padx=5)ttk.Button(btn_frame, text="转小写", command=self.convert_lower).pack(side='left', padx=5)ttk.Button(btn_frame, text="清空", command=self.clear_text).pack(side='left', padx=5)ttk.Button(btn_frame, text="字数统计", command=self.count_words).pack(side='left', padx=5)def setup_file_tab(self):frame = ttk.LabelFrame(self.tab2, text="文件操作", padding=10)frame.pack(fill='both', expand=True, padx=5, pady=5)ttk.Button(frame, text="选择文件", command=self.select_file).pack(pady=5)self.file_label = ttk.Label(frame, text="未选择文件")self.file_label.pack(pady=5)self.file_content = tk.Text(frame, height=10)self.file_content.pack(fill='both', expand=True, pady=5)ttk.Button(frame, text="保存内容", command=self.save_file).pack(pady=5)def setup_calc_tab(self):frame = ttk.LabelFrame(self.tab3, text="简单计算器", padding=10)frame.pack(fill='both', expand=True, padx=5, pady=5)# 输入框input_frame = ttk.Frame(frame)input_frame.pack(fill='x', pady=5)ttk.Label(input_frame, text="数字1:").pack(side='left')self.num1 = ttk.Entry(input_frame, width=10)self.num1.pack(side='left', padx=5)ttk.Label(input_frame, text="数字2:").pack(side='left')self.num2 = ttk.Entry(input_frame, width=10)self.num2.pack(side='left', padx=5)# 计算按钮btn_frame = ttk.Frame(frame)btn_frame.pack(fill='x', pady=5)ttk.Button(btn_frame, text="+", command=lambda: self.calculate('+')).pack(side='left', padx=5)ttk.Button(btn_frame, text="-", command=lambda: self.calculate('-')).pack(side='left', padx=5)ttk.Button(btn_frame, text="×", command=lambda: self.calculate('*')).pack(side='left', padx=5)ttk.Button(btn_frame, text="÷", command=lambda: self.calculate('/')).pack(side='left', padx=5)# 结果显示self.result_label = ttk.Label(frame, text="结果: ")self.result_label.pack(pady=5)# 文本处理功能def convert_upper(self):text = self.text_input.get("1.0", tk.END)self.text_input.delete("1.0", tk.END)self.text_input.insert("1.0", text.upper())self.status_bar.config(text="文本已转换为大写")def convert_lower(self):text = self.text_input.get("1.0", tk.END)self.text_input.delete("1.0", tk.END)self.text_input.insert("1.0", text.lower())self.status_bar.config(text="文本已转换为小写")def clear_text(self):self.text_input.delete("1.0", tk.END)self.status_bar.config(text="文本已清空")def count_words(self):text = self.text_input.get("1.0", tk.END).strip()words = len(text.split())chars = len(text)messagebox.showinfo("统计结果", f"字数统计:\n单词数:{words}\n字符数:{chars}")# 文件操作功能def select_file(self):file_path = filedialog.askopenfilename()if file_path:self.file_label.config(text=file_path)try:with open(file_path, 'r', encoding='utf-8') as file:content = file.read()self.file_content.delete("1.0", tk.END)self.file_content.insert("1.0", content)self.status_bar.config(text=f"已打开文件:{os.path.basename(file_path)}")except Exception as e:messagebox.showerror("错误", f"无法打开文件:{str(e)}")def save_file(self):file_path = filedialog.asksaveasfilename(defaultextension=".txt")if file_path:try:content = self.file_content.get("1.0", tk.END)with open(file_path, 'w', encoding='utf-8') as file:file.write(content)self.status_bar.config(text=f"文件已保存:{os.path.basename(file_path)}")except Exception as e:messagebox.showerror("错误", f"保存失败:{str(e)}")# 计算器功能def calculate(self, operator):try:num1 = float(self.num1.get())num2 = float(self.num2.get())if operator == '+':result = num1 + num2elif operator == '-':result = num1 - num2elif operator == '*':result = num1 * num2elif operator == '/':if num2 == 0:raise ValueError("除数不能为零")result = num1 / num2self.result_label.config(text=f"结果: {result:.2f}")self.status_bar.config(text="计算完成")except ValueError as e:messagebox.showerror("错误", str(e))except Exception as e:messagebox.showerror("错误", "请输入有效的数字")if __name__ == '__main__':root = tk.Tk()app = MyApp(root)root.mainloop()

程序运行界面如下图

打包

在test.list中可以看到打包好的依赖项,执行exe,如下图,正常运行。

总结

不同于其他打包工具,nuitka是将python代码,转换成C代码,在通过C编译器编译成可执行文件。

优势:支持外部资源,支持windows、linux、以及macOS系统。Nuitka --help可以查看所有命令参数。

http://www.dtcms.com/wzjs/840158.html

相关文章:

  • 凡科和有赞哪个好用网络优化工程师面试题
  • 网站建设选哪家河北省建设工程招标投标协会网站
  • 枣庄网站建设制作做电商怎么找货源
  • 湖南土建网性价比高seo排名
  • 网站文案优化导购网站怎么推广
  • 网站建设小程序开发报价英语可以做推广的亲子类网站
  • 外贸网站推广方法之一指数基金排名前十名
  • 湖南定制响应式网站有哪些网站怎样优化seo
  • 最新注册的公司在哪里可以查询系统优化升级95%后不动了
  • 网站建设待遇怎样吉安网站建设兼职
  • 常用的网站开发语言有哪些制作图片的电脑软件
  • 企业网站多大空间够用明港seo公司
  • 网站改版一般需要多久网站制作需要哪些东西
  • app网站开发成功案例深圳优化网站公司
  • 重庆欧勒精细有限公司网站策划书wordpress情侣博客模板下载
  • 网站建设与管理多选题计算机网络技术就业公司
  • 网站网站在国外百度收录查询
  • 做厂房出租有那些推广网站设计个网站多少钱
  • 青岛 机械 中企动力提供网站建设淮安市住房和城乡建设局网站首页
  • 发布网站的空间wordpress 内存占用
  • ASP做旅游网站代码最流行的网站设计风格
  • 中国著名设计建筑seo有哪些网站
  • 广告网址wordpress配置搜索引擎优化
  • 中国网站建设公司有哪些方面买到域名怎么做网站
  • 怎样怎样优化网站建设面试学校网站开发
  • 网页制作与网站管理东莞技术支持 骏域网站建设
  • 哪个网站seo做的最好三星做号网站
  • 济南网站建设与维护旅游网站建设毕业设计
  • 安利的网站谁做的浏览器打不开网页但能上网
  • 如何做网站描述ue4培训