2两肉 发表于 2020-7-2 21:00:06

随机模块怎么总是报错

import random
times = 3
secret = random.randint(1,10)
print('-------------我爱鱼C工作室-------------')
guess = 0
temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:",end="")
while (guess != secret) and (times > 0):
    temp = input()
    guess = int(temp)
    times = times - 1
    if guess ==secret:
      print("你是小甲鱼心里的蛔虫吗?!")
      print("哼,猜中了也没有奖励!")
    else:
      if guess >secret:
         print("哥,大了大了")
      else:
            print ("嘿,小了小了")
      if times > 0:
            print("再试一次吧:", end = " ")
      else:
            print("机会用光喽")
print("游戏结束,不玩啦")


报错内容
-------------我爱鱼C工作室-------------
Traceback (most recent call last):
File "C:/python3练习题/2.py", line 6, in <module>
    temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:",end="")
TypeError: input() takes no keyword arguments

Twilight6 发表于 2020-7-2 21:01:35



input("不妨猜一下小甲鱼现在心里想的是哪个数字:",end="")

input 函数没有 end 参数去掉就好了


suchocolate 发表于 2020-7-2 21:10:15

temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:")

2两肉 发表于 2020-7-2 21:19:47

suchocolate 发表于 2020-7-2 21:10


已解决,谢谢你
页: [1]
查看完整版本: 随机模块怎么总是报错