小白疑问
请问为什么保存了小甲鱼教的第一个小游戏 py文件之后再打开玩到最后直接闪退,没有打印结束语言的?import random
answer=random.randint(1,10)
count=3
print("guess my number?")
while count>0:
temp=input()
while not temp.isdigit():
temp=input("please input a digit")
guess=int(temp)
if guess==answer:
print("congrats, you got that right!")
else:
count=count-1
if guess>answer:
print("kinda big")
else:
print("kinda small")
if count>0:
print("try again")
else:
print("your chances are out")
print("game over")
不是闪退 是太快了 你看不见 哈哈 // 一执行完程序就自动退出了
试试在文件末尾加上一句 input() 吧 {:10_330:}
<font color="red">[已解决]</font>python运行时闪退,是什么原因
https://fishc.com.cn/thread-160190-1-1.html
(出处: 鱼C论坛)
Python FAQ 017 双击运行程序闪退
https://fishc.com.cn/thread-159173-1-1.html
(出处: 鱼C论坛)
import random
secret = random.randint(1,10)
print('----------------我爱鱼C工作室---------------')
temp = input("不妨猜一下小甲鱼现在心里想的是那个数字:")
guess = int(temp)
while guess != secret:
temp = input("哎呀,猜错了,请重新输入吧:")
guess = int(temp)
if guess == secret:
print("我草,你是小甲鱼心里的蛔虫吗?!")
print("哼,猜中里也没有奖励!")
else:
if guess > secret:
print("哥,大了大了~~~~")
else:
print("嘿,小了,小了~~~~")
print("游戏结束,不玩了^-^") 右键用edit with idle打开,黑框是python解释器,运行完就直接退出了(遇到bug也会),所以改代码时,就用idle打开。 请见:https://fishc.com.cn/thread-159173-1-1.html 在结尾加上一个“input()”就不会闪退了,要按一次回车才会退出
import random
answer=random.randint(1,10)
count=3
print("guess my number?")
while count>0:
temp=input()
while not temp.isdigit():
temp=input("please input a digit")
guess=int(temp)
if guess==answer:
print("congrats, you got that right!")
else:
count=count-1
if guess>answer:
print("kinda big")
else:
print("kinda small")
if count>0:
print("try again")
else:
print("your chances are out")
print("game over")
input()
就这样 结尾加上input()就行啦 加上input 是太快了你没看见哈哈哈哈,, 直接打开的话后面必须加一个input语句,如果在IDLE里面打开则不用加 一输出就关闭了,看不见,最后加input就行 看看这个主题:https://fishc.com.cn/thread-159173-1-1.html 请选择最佳答案,结帖
我认为 Judie 的应为最佳答案 Judie 发表于 2020-4-7 03:52
不是闪退 是太快了 你看不见 哈哈 // 一执行完程序就自动退出了
试试在文件末尾加上一句 input() 吧 {:1 ...
谢谢~{:5_105:} XiaoPaiShen 发表于 2020-4-6 23:35
请选择最佳答案,结帖
我认为 Judie 的应为最佳答案
{:10_256:} 谢谢您 珍珠是认真的 发表于 2020-4-7 03:05
谢谢~
{:10_282:} 不客气。
页:
[1]