【发布时间】:2017-11-14 15:17:32
【问题描述】:
我是编程新手。我用python写了一个小程序,并将其转换为带有pyinstaller的.exe文件。现在,当我尝试打开 .exe 文件时,会出现黑屏并立即关闭。我能够得到一个截图:
我看到了一个解决方案,比如在代码末尾添加input(),但它也不起作用。我的代码:
import random
print("Hello, what is your name?")
name = str(input())
print("Well, " + name + ", I think of a number between 1 and 1000. Can you guess this number in 10 chances?")
number = random.randint(1, 1001)
for guessTaken in range(1, 11):
print("Take a guess")
guess = int(input())
if guess > number:
print("The number you think is too high")
elif guess < number:
print("The number you think is too low")
else:
break
if guess == number:
print("OK, " + name + ", you guessed the number in " + str(guessTaken) + " guesses")
else:
print("Unfortunatelly, you couldn't find the number. The number is " + str(number))
【问题讨论】:
标签: python pyinstaller