Python指令碼生成可執行檔案 (戀愛小指令碼)

2022-09-20 14:27:12 字數 2568 閱讀 2285

概述:因此直接打包生成可執行檔案(.exe)檔案,可以良好進行使用。

# 如果有虛擬環境則進入虛擬環境

pip install pyinstaller

表1

-h,--help

檢視該模組的幫助資訊

-f,-onefile

產生單個的可執行檔案

-d,--onedir

產生乙個目錄(包含多個檔案)作為可執行程式

-a,--ascii

不包含 unicode 字符集支援

-d,--debug

產生 debug 版本的可執行檔案

-w,--windowed,--noconsolc

指定程式執行時不顯示命令列視窗(僅對 windows 有效)

-c,--nowindowed,--console

指定使用命令列視窗執行程式(僅對 windows 有效)

-o dir,--out=dir

指定 spec 檔案的生成目錄。如果沒有指定,則預設使用當前目錄來生成 spec 檔案

-p dir,--path=dir

設定 python 匯入模組的路徑(和設定 pythonpath 環境變數的作用相似)。也可使用路徑分隔符(windows 使用分號,linux 使用冒號)來分隔多個路徑

-n name,--name=name

指定專案(產生的 spec)名字。如果省略該選項,那麼第乙個指令碼的主檔名將作為 spec 的名字

在 表1 中列出的只是pyinstaller模組所支援的常用選項,如果需要了解 pyinstaller 選項的詳細資訊,則可通過 pyinstaller -h 來檢視。

# -*- coding: utf-8 -*-

'''@time : 2022/2/9 15:12

@author : ziqingbaojian

@file : draw.py

'''import turtle

import time

def littleheart():

for i in range(200):

turtle.right(1)

turtle.forward(2)

islove = str(input('你會一直愛她嗎?(y or n)\n')).upper()

run=1

while (run):

if islove == "y":

me = ""

love = ""

if love == '':

love = ' 傻狗喜歡你 '

turtle.setup(width=900, height=500)

turtle.color('red', 'red')

turtle.pensize(3)

turtle.speed(50)

turtle.up()

turtle.hideturtle()

turtle.goto(0, -180)

turtle.showturtle()

turtle.down()

turtle.speed(5)

turtle.begin_fill()

turtle.left(140)

turtle.forward(224)

littleheart()

turtle.left(120)

littleheart()

turtle.forward(224)

turtle.end_fill()

turtle.pensize(5)

turtle.up()

turtle.hideturtle()

turtle.goto(0, 0)

turtle.showturtle()

turtle.color('#cd5c5c', 'blue')

turtle.write(love, font=('gungsuh', 30,), align="center")

turtle.up()

turtle.hideturtle()

if me != '':

turtle.color('yellow', 'red')

time.sleep(2)

turtle.goto(180, -180)

turtle.showturtle()

turtle.write(me, font=(20,), align="center", move=true)

window = turtle.screen()

window.exitonclick()

run = 0

else:

print("活該單身一輩子")

print("!!!!!!!!!再給你一次機會!!!!!!!!")

islove = input('你會一直愛她嗎?(y or n)\n')

python指令碼執行可執行檔案

python import os device r usbstor disk ven generic prod sd mmc rev 1.00 20100818841300000 0 blocksieze 32kb time 00 00 05 00 mode sr sw sv xr xw xv pa...

Python 生成可執行檔案

準備 開發環境python3 首先需要安裝第三方庫 pyinstaller pip直接安裝庫如果遇到各種問題,戳這裡 接下來 從shell中進入cmd視窗 import os os.system cmd 在cmd視窗中輸入 pyinstaller c f main.py 注 main.py是main...

Python生成exe可執行檔案

f 表示生成單個可執行檔案 d onedir 建立乙個目錄,包含exe檔案,但會依賴很多檔案 預設選項 w 表示去掉控制台視窗,這在gui介面時非常有用。不過如果是命令列程式的話那就把這個選項刪除吧!c console,nowindowed 使用控制台,無介面 預設 p 表示你自己自定義需要載入的類...