特定单词的一个匹配项

2024-10-02 08:16:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我在匹配一个单词时遇到问题。我正在制作一个slack bot,但是我在使用regex时遇到了一些困难,下面是中断我的程序的代码:

@listen_to(r'(?:\W|^)(CTRG|Viper)(?:\W|$)', re.IGNORECASE)
def refme_send(message):
    sleep(1)
    answers = ('You\'re not supposed to talk about it.', 'This information is classified!')
    message.send(answers[randrange(0, len(answers))])

这是我在测试时遇到的错误:

Traceback (most recent call last):
  File "/home/my_user/.slack/SlackBot/lib/python3.5/site-packages/slackbot/dispatcher.py", line 55, in _dispatch_msg_handler
    func(Message(self._client, msg), *args)
TypeError: hello_reply() takes 1 positional argument but 2 were given

谢谢你的帮助。你知道吗


Tags: to代码程序resendmessagebotmsg

热门问题