我正在编写Python游戏,它说空间和凹痕有奇怪的使用。我不知道为什么,因为对我来说似乎完全很好。为什么不起作用?
import random
import time
from time import sleep
import sys
class Stats:
def __init__(self, hunger, dehydration, phys_strength, mental_strength, psychic_powers, intelligence):
self.hunger = hunger
self.dehydration = dehydration
self.phys_strength = phys_strength
self.mental_strength = mental_strength
self.psychic_powers = psychic_powers
self.intelligence = intelligence
hero_stats = Stats(10, 10, 10, 20, 0, 20)
hunger_info = f"Your hunger level is {hero_stats.hunger}. Your stomach is full when you are at 0, and you starve at 100."
def user_input(input1):
if input1.lower() == "hunger info":
printfast("n")
printfast(hunger_info)
错误:
Python Files xxxxxxxxxxxxxx$ python3 adventuregame.py
File "adventuregame.py", line 36
printfast(hunger_info)
^
TabError: inconsistent use of tabs and spaces in indentation
xxxxxxx-Air:Python Files xxxxxxxxxxxxxx$
在上一行的 printfast("n")
之前有一个选项卡,而缩进的其余部分是用空格完成的。
您应该始终使用将选项卡转换为4个空格的编辑器。