我正在制作一个快速的1小时游戏,完成了大约一半,出现了TypeError: 'builtin_function_or_method' object is not subscriptable
错误。我不知道为什么会发生这种情况,使用time.sleep[x]
函数似乎有一些问题。我的全部错误和代码如下。在
代码:
import time
import random
def intro():
print("You are playing a game...")
time.sleep[3]
print("of chance.")
time.sleep[1.5]
print("Enter [1] to continue.")
introChoice=''
while introChoice not in ['1']:
introChoice=input("> ")
if introChoice=="1":
tutorial()
错误:
^{pr2}$如果有需要,我愿意提供更多的信息。在
您混淆了Python语法的两个非常不同的东西。
[]
是一个索引符号;myindexable[i]
表示myindexable
中的第i
项。()
是调用函数的符号;myfunc(n)
用参数n
调用函数myfunc
。在sleep
是一个函数/方法,而不是一个可索引的对象。你这样称呼它:不像:
^{pr2}$相关问题 更多 >
编程相关推荐