擅长:python、mysql、java
<p>实际上你在这里(称之为)</p>
<pre><code>bestiary = {
'Goblin': goblin.describe()
}
</code></pre>
<p>您可以尝试返回字符串,而不只是打印它:</p>
<pre><code>import dice #a dice module i made
import textwrap
class Goblin(object):
def __init__(self):
self.name = 'Goblin'
self.desc = 'bla bla bla, I''m not going to type the whole thing.'
self.health = dice.d8.roll(1) + 1
def describe(self):
return self.name + " " + self.health + " " + 'other random info not in self.desc ' \
+ 'other random info not in self.desc ' + textwrap.fill(self.desc, 60)
goblin = Goblin()
bestiary = {
'Goblin': goblin.describe()
}
</code></pre>