【发布时间】:2017-09-23 14:32:21
【问题描述】:
我知道这可能非常简单,我忘记了一些东西,但我不记得如何打印字典的键。具体问题是我有一个可以攻击的动物部分的字典,值是用于攻击的动词,例如:{'teeth': 'bites'}
看起来像这样:
attack_part = random.choice(list(self.attacking_parts))
print('The', self.name, self.attacking_parts[attack_part], 'you with their', self.attacking_parts.keys() + '!')
但是当我使用它时会发生什么:
The bear scratches you with their scrathes!
【问题讨论】:
标签: python dictionary