我对 Python(以及一般的编程)相当陌生,所以请原谅我对一些你可能会发现的东西缺乏知识或理解。不过我不傻,所以希望我能解决这个问题。
我正在制作一个基于文本的小型生存游戏,但遇到了一个我似乎无法解决的问题,即:
AttributeError: 'int' 对象没有属性 'sleep'
当我尝试运行我的程序时在控制台中。
import time , sys , random , shelve
# /gather command
if '/gather' in Input and command_state == True:
if 'wood' in Input:
print('Collecting wood...')
if tool != "Axe":
time.sleep(random.randrange(5 , 10))
print("Test")
else:
time.sleep(random.randrange(5 , 10))
print("Test")
Run Code Online (Sandbox Code Playgroud)
我真的不明白是什么导致了这种情况,在查看了有关类似主题的建议后,我没有找到解决方案。任何帮助,将不胜感激!
如果你想让我把整个剧本放上来,请尽管问。我只列出了导致问题的代码块(因为其他代码似乎都没有影响这里的任何内容)。
| 归档时间: |
|
| 查看次数: |
15602 次 |
| 最近记录: |