Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 电报机器人——在字典中实现搜索_Python_Python 2.7_Dictionary_Telegram Bot - Fatal编程技术网

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,真)