书中代码有一处是这样写的
for k,v in self.ladders.items(): self.ladders[v] = k print('ladders info:') print(self.ladders) print('dice ranges:') print(self.dices) self.pos = 1
本质上没有任何问题,但是我是python3.5的版本,字典这一块就用不了,所以会出现如下错误:
for k,v in self.ladders.items():
RuntimeError: dictionary changed size during iteration
所以代码进行如下改变就好用了。
for k,v in list(self.ladders.items()): self.ladders[v] = k print('ladders info:') print(self.ladders) print('dice ranges:') print(self.dices) self.pos = 1