Python Cx_Freeze终端无法正常打开(以前工作过)

时间:2018-07-19 17:15:25

标签: python python-3.x exe python-3.6 cx-freeze

已经在python中制作了一种随机的模因生成器。已经把它变成了exe文件。

以下是随机模因的代码:

import random as r
import webbrowser as wb
import os

totalLines = 0
var = 0
loop = 1
version = "0.2.5"
prevVideo = ""
while True:
    os.system('cls' if os.name == 'nt' else 'clear')


    loop = 1
    print("Random Meme Chooser")
    print("Version: "+version)
    menu = input("Type (A) for adding a meme or (R) for a random meme: ")
    if menu in ("A","a"):
        newVideo = input("Enter a YouTube link: ")
        f = open("memeList.mem,","r")
        for line in f:
            if newVideo in line:
                print("That link is already added, idiot")
                var = 1 
        if var == 0:
            f = open("memeList.mem","a")
            f.write(newVideo+"\n")
            f.close()
    elif menu in ("R","r"):
        while loop == 1:


            with open('memeList.mem') as f:
                totalLines=(sum(1 for _ in f))

            random = r.randrange(1,totalLines+1)
            f = open("memeList.mem", "r")
            lines = f.readlines()
            f.close()
            random -= 1
            video = lines[random]
            if video == prevVideo:
                with open('memeList.mem') as f:
                    totalLines=(sum(1 for _ in f))

                random = r.randrange(1,totalLines+1)
                f = open("memeList.mem", "r")
                lines = f.readlines()
                f.close()
                random -= 1
                video = lines[random]
                print("Duplicate found, finding new video...")
            elif video != prevVideo:
                prevVideo = video
                wb.open(video)
                loop = 0
    else:
        print("Please only enter A or R")

这是setup.py代码

from cx_Freeze import setup, Executable




setup(name = "Random Memes 0.2.5",
    version = "1.0",
    description = "ssd",
    executables = [Executable("Random Memes 0.2.5.py")]
    )

我已经在CMD中尝试过,并且效果很好。 尝试使用.txt而不是.mem进行尝试,就像之前仍然错误尝试删除导入的OS和os.system(“ cls .....)

关于为什么我的EXE无法正常打开的任何想法在此之前都可以正常工作

0 个答案:

没有答案