我有这个完全荒谬的错误,我已经完全放弃了。这是我的代码:
class SaveGame:
def __init__ (self):
self.stats ={'strength':player.strength, 'dexterity':player.dexterity, 'inventory':player.inventory, 'read-inventory':player._inventory, 'equipped weapons':player.equippedweapons, 'Consumable supply':procs.consum, 'Health':procs.health, 'poisoned?':procs.poison, 'storypointe':storypointe}
def save (self):
try:
with open (savefile, 'wb') as savebin:
pickle.dump (self.stats, savefile)
except KeyError:
print "Unable to load game"
sys.exit (0)
def load (self):
pickle.load (savefile)
现在,当我去实现时......:
startgame = raw_input ("Would you like to load your game or start a new one\n>>> ")
if startgame in ['load game', 'load my game', 'Load my game', 'Load game', 'load', 'Load']:
loadedgame = SaveGame ()
loadedgame.load ()
我收到此错误:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import ModRpg
File "C:\Users\Sammu\The Folder\ModRpg.py", line 317, in <module>
loadedgame.load ()
AttributeError: SaveGame instance has no attribute 'load'