我目前正在使用python-jabberbot并且无法创建一个发送随机句子的简单方法。我不精通python,所以我想知道我哪里出错了。我有一种感觉,我声明数组的方式是我的失败:
def whatdoyouknow(self, mess, args):
"""random response"""
string[0] = 'this is a longish sentence about things'
string[1] = 'this is a longish sentence about things number 2'
string[2] = 'this is a longish sentence about things number 3'
i = random.randint(0, 2)
return string[i]