Python interacts with the Turing Machine 2 (Build smarter Robots)

Source: Internet
Author: User

 #!/usr/bin/env python 
#-*-coding:utf-8-*-@Author: WUJF @Time: 2018/9/5 17:42
Import requests
Import Itchat
Import sys
Reload (SYS)
sys.setdefaultencoding (' UTF8 ')


def get_response (_info):
Print (_info) # Messages sent from a friend
Api_url = ' Http://www.tuling123.com/openapi/api ' # turing man URL
data = {
' k EY ': ' 7920999ef510477d93344ff2106e96ef ', # If this apiKey is not available, register
' info ': _info, # This is the message we received from a friend and forwarded to the Turing Man br> ' userid ': ' Wechat-robot ', # Here's what you want to change.
}
R = Requests.post (Api_url, Data=data). JSON () # Put the data Send
Print (R.get (' text)) # Robot reply message to friend
return R


@itchat. Msg_register (Itchat.content.TEXT)
Def t Ext_reply (msg):
Return Get_response (msg["text"]) ["text"]


If __name__ = = ' __main__ ':
Itchat.auto_ Login () # hotreload = True, keep online, the next run code can be automatically logged in hotreload=true (to be removed on Linux)
Itchat.run ()
is available on Windows, put on Linux error, Remove the
Itchat.auto_login (), no error, but does not work, to find the cause of

Python interacts with the Turing Machine 2 (Build smarter Robots)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.