资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

如何让别人用我的Python程序-创新互联

创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

创新互联公司:于2013年开始为各行业开拓出企业自己的“网站建设”服务,为近1000家公司企业提供了专业的网站设计制作、成都网站建设、网页设计和网站推广服务, 按需设计网站由设计师亲自精心设计,设计的效果完全按照客户的要求,并适当的提出合理的建议,拥有的视觉效果,策划师分析客户的同行竞争对手,根据客户的实际情况给出合理的网站构架,制作客户同行业具有领先地位的。

小编给大家分享一下如何让别人用我的Python程序,相信大部分人都还不怎么了解,因此分享这边文章给大家学习,希望大家阅读完这篇文章后大所收获,下面让我们一起去学习方法吧!

别人怎么用我的Python程序

这里讲的给别人用,不是指将你的代码开源,也不是指给另一个程序员用。比如你写了一个小工具,想给别人用,总不能叫别人也去装python吧。

让别人不装Python环境就可以使用Python编写的程序,可以将Python程序打包.exe可执行程序,然后发给他人。

推荐学习《Python教程》。

Python打包生成.exe文件的工具有:

1、py2exe

使用:

先写一个简单的脚本,文件名:helloworld.py

#!/usr/bin/env python  # -*- coding: utf-8 -*-  
  def say_hello(name):  
    print("Hello, " + name)
  if __name__ == "__main__":  
    name = input("What's your name:")
    say_hello(name)

还需要个用于发布程序的设置脚本:mysetup.py,在其中的 setup 函数前插入语句 import py2exe。

from distutils.core import setupimport py2exe
setup(console=["helloworld.py"])

2、cx_Freeze

使用:cxfreeze main.py --target-dir dist

Usage: cxfreeze [options] [SCRIPT]

Freeze a Python script and all of its referenced modules to a base
executable which can then be distributed without requiring a Python
installation.

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -O                    optimize generated bytecode as per PYTHONOPTIMIZE; use
                        -OO in order to remove doc strings
  -c, --compress        compress byte code in zip files
  -s, --silent          suppress all output except warnings and errors
  --base-name=NAME      file on which to base the target file; if the name of
                        the file is not an absolute file name, the
                        subdirectory bases (rooted in the directory in which
                        the freezer is found) will be searched for a file
                        matching the name
  --init-script=NAME    script which will be executed upon startup; if the
                        name of the file is not an absolute file name, the
                        subdirectory initscripts (rooted in the directory in
                        which the cx_Freeze package is found) will be searched
                        for a file matching the name
……
……
……

3、PyInstaller

使用:pyinstaller demo.py

如何让别人用我的Python程序

以上是如何让别人用我的Python程序的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联-成都网站建设公司行业资讯频道!


网站题目:如何让别人用我的Python程序-创新互联
本文网址:http://cdkjz.cn/article/djjepi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220