发送一个可执行的Python文件给某人[重复]。

问题描述 投票:0回答:2

我做了一个项目,我想把它发给我的朋友们看,并尝试。

问题是,一旦我把它变成一个可执行文件,我就不能把它送到任何地方了

他们没有安装python,所以我不能只发送文件,我想知道有什么可能性发送可执行文件。

我试着重命名文件的扩展名,发送,但他不能运行它。

我想知道,如果没有安装python,windows是否有可能无法编译或打开可执行文件?

这就是代码

from tkinter import *

tura=0

def golire(parent):
    for elemente in parent.winfo_children():
        elemente.grid_forget()

def terminare(parent,castigator,joc_nou):
    global tura
    tura=0
    golire(parent)
    afis=Label(parent,text=castigator+' a castigat!',font=('Arial',30),width=20,height=3)
    buton1=Button(parent,text='Din nou?',font=('Courier',10),width=5,height=5,command=joc_nou)
    buton2=Button(parent,text='Neah',font=('Courier',10),width=5,height=5,command=root.quit)

    afis.grid(columnspan=2,sticky=NSEW)
    buton1.grid(row=1,column=0,sticky=NSEW)
    buton2.grid(row=1,column=1,sticky=NSEW)

class joc:
    def __init__(self,parent):
        global tura

        tura=0

        self.parent=parent

        b0=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b0.grid(row=0,column=0,sticky=NSEW)

        b1=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b1.grid(row=0,column=1,sticky=NSEW)

        b2=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b2.grid(row=0,column=2,sticky=NSEW)

        b3=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b3.grid(row=1,column=0,sticky=NSEW)

        b4=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b4.grid(row=1,column=1,sticky=NSEW)

        b5=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b5.grid(row=1,column=2,sticky=NSEW)

        b6=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b6.grid(row=2,column=0,sticky=NSEW)

        b7=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b7.grid(row=2,column=1,sticky=NSEW)

        b8=Label(self.parent,text='',font=('Arial',30),width=7,height=3,relief='groove')
        b8.grid(row=2,column=2,sticky=NSEW)

        def enter(event):
            event.widget.config(bg='black')
        def left(event):
            event.widget.config(bg='white')

        def adaugare(event):
            global tura
            if event.widget['state']!='disabled':
                if tura%2==0:
                    event.widget.config(text='X')
                else:
                    event.widget.config(text='O')
                event.widget.config(state='disabled')
                tura+=1
        def verificare(event):
            def joc_nou():
                golire(self.parent)
                joc(self.parent)

            if b0['text']==b1['text']==b2['text'] and b0['state']==b1['state']==b2['state']=='disabled':
                terminare(self.parent,b0['text'],joc_nou)
            elif b3['text']==b4['text']==b5['text'] and b3['state']==b4['state']==b5['state']=='disabled':
                terminare(self.parent,b3['text'],joc_nou)
            elif b6['text']==b7['text']==b8['text'] and b6['state']==b7['state']==b8['state']=='disabled':
                terminare(self.parent,b6['text'],joc_nou)
            elif b0['text']==b3['text']==b6['text'] and b0['state']==b3['state']==b6['state']=='disabled':
                terminare(self.parent,b0['text'],joc_nou)
            elif b1['text']==b4['text']==b7['text'] and b1['state']==b4['state']==b7['state']=='disabled':
                terminare(self.parent,b1['text'],joc_nou)
            elif b2['text']==b5['text']==b8['text'] and b2['state']==b5['state']==b8['state']=='disabled':
                terminare(self.parent,b0['text'],joc_nou)
            elif b0['text']==b4['text']==b8['text'] and b0['state']==b4['state']==b8['state']=='disabled':
                terminare(self.parent,b0['text'],joc_nou)
            elif b2['text']==b4['text']==b6['text'] and b2['state']==b4['state']==b6['state']=='disabled':
                terminare(self.parent,b0['text'],joc_nou)
            elif b0['state']==b1['state']==b2['state']==b3['state']==b4['state']==b5['state']==b6['state']==b7['state']==b8['state']=='disabled':
                terminare(self.parent,'Nimeni',joc_nou)


        b0.bind("<Enter>",enter)
        b0.bind("<Leave>",left)

        b1.bind("<Enter>",enter)
        b1.bind("<Leave>",left)

        b2.bind("<Enter>",enter)
        b2.bind("<Leave>",left)

        b3.bind("<Enter>",enter)
        b3.bind("<Leave>",left)

        b4.bind("<Enter>",enter)
        b4.bind("<Leave>",left)

        b5.bind("<Enter>",enter)
        b5.bind("<Leave>",left)

        b6.bind("<Enter>",enter)
        b6.bind("<Leave>",left)

        b7.bind("<Enter>",enter)
        b7.bind("<Leave>",left)

        b8.bind("<Enter>",enter)
        b8.bind("<Leave>",left)

        b0.bind("<Button-1>",adaugare,add="+")

        b1.bind("<Button-1>",adaugare,add="+")

        b2.bind("<Button-1>",adaugare,add="+")

        b3.bind("<Button-1>",adaugare,add="+")

        b4.bind("<Button-1>",adaugare,add="+")

        b5.bind("<Button-1>",adaugare,add="+")

        b6.bind("<Button-1>",adaugare,add="+")

        b7.bind("<Button-1>",adaugare,add="+")

        b8.bind("<Button-1>",adaugare,add="+")

        #verificare
        b0.bind("<Button-1>",verificare,add="+")

        b1.bind("<Button-1>",verificare,add="+")

        b2.bind("<Button-1>",verificare,add="+")

        b3.bind("<Button-1>",verificare,add="+")

        b4.bind("<Button-1>",verificare,add="+")

        b5.bind("<Button-1>",verificare,add="+")

        b6.bind("<Button-1>",verificare,add="+")

        b7.bind("<Button-1>",verificare,add="+")

        b8.bind("<Button-1>",verificare,add="+")



if __name__=='__main__':
    root=Tk()
    joc(root)
    root.mainloop()
python python-3.x executable send
2个回答
0
投票

你有两个选择

  1. 说服他们安装python
  2. 用一个工具把它打包,比如 PyInstallerpy2exe然后把编译后的可执行文件发给他们

0
投票

我总是用 PyInstaller 为此,安装简单,使用方便。

© www.soinside.com 2019 - 2024. All rights reserved.