I'm trying to read a dictionary off a file and then make the string into a dictionary. I have this,
with open("../resources/enemyStats.txt", "r") as stats:
for line in stats:
if self.kind in line:
line = line.replace(self.kind + " ", "")
line = dict(line)
return line
and the line in the txt file is,
slime {'hp':5,'speed':1}
I'd like to be able to return a dict so that I can easily access the hp and other values for the enemy character.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…