Python 电报机器人——在字典中实现搜索
我正在创建一个电报机器人,用于在在线词典中搜索单词,当我需要在电报中创建用于在该词典中搜索的命令时,问题就出现了,此时我有以下信息:Python 电报机器人——在字典中实现搜索,python,python-2.7,dictionary,telegram-bot,Python,Python 2.7,Dictionary,Telegram Bot,我正在创建一个电报机器人,用于在在线词典中搜索单词,当我需要在电报中创建用于在该词典中搜索的命令时,问题就出现了,此时我有以下信息: from rae import Drae drae = Drae() if text.startswith('/'): if text =='/define': drae.search(u' ') # The problem is here, I don't know how to implement the command an
from rae import Drae
drae = Drae()
if text.startswith('/'):
if text =='/define':
drae.search(u' ') # The problem is here, I don't know how to implement the command and the word who the client wants to search.
setEnabled(chat_id, True)
- 我在Python中使用这个电报API:
- 字典的API是:
- 这个怎么样
from rae import Drae
drae = Drae()
if text.startswith('/'):
if text.startswith('/define'):
try:
[command, data] = text.split(' ',1)
except:
send('Write: /define <word>')
meanings = drae.search(data)
reply(str(meanings))
setEnabled(chat_id, True)
从rae导入Drae
drae=drae()
如果text.startswith(“/”):
如果text.startswith('/define'):
尝试:
[命令,数据]=text.split(“”,1)
除:
发送('写入:/define')
含义=drae.search(数据)
答复(str(含义))
setEnabled(聊天室id,真)