小編給大家分享一下如何讓別人用我的Python程序,相信大部分人都還不怎么了解,因此分享這邊文章給大家學(xué)習,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去學(xué)習方法吧!
創(chuàng)新互聯(lián)建站主營韶山網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,App定制開發(fā),韶山h5微信小程序開發(fā)搭建,韶山網(wǎng)站營銷推廣歡迎韶山等地區(qū)企業(yè)咨詢
別人怎么用我的Python程序
這里講的給別人用,不是指將你的代碼開源,也不是指給另一個程序員用。比如你寫了一個小工具,想給別人用,總不能叫別人也去裝python吧。
讓別人不裝Python環(huán)境就可以使用Python編寫的程序,可以將Python程序打包.exe可執(zhí)行程序,然后發(fā)給他人。
推薦學(xué)習《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)
還需要個用于發(fā)布程序的設(shè)置腳本:mysetup.py,在其中的 setup 函數(shù)前插入語句 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程序的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
分享標題:如何讓別人用我的Python程序
當前URL:http://jinyejixie.com/article46/pgishg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、外貿(mào)建站、全網(wǎng)營銷推廣、服務(wù)器托管、用戶體驗、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)