python 调用图灵机器人api实现简单的人机交互
2014-10-26 16:58
671 查看
接入流程如下,需要先注册开发者帐号,之后会得到一个32位的key,保存下来,用于以后发送数据。http://www.tuling123.com/
请求方式
示例:
# -*- coding: utf-8 -*-
import urllib
import json
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
if __name__ == '__main__':
key = '8b005db5f57556fb96dfd98fbccfab84'
api = 'http://www.tuling123.com/openapi/api?key=' + key + '&info='
while True:
info = raw_input('我: ')
request = api + info
response = getHtml(request)
dic_json = json.loads(response)
print '机器人: '.decode('utf-8') + dic_json['text']
请求方式
示例:
# -*- coding: utf-8 -*-
import urllib
import json
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
if __name__ == '__main__':
key = '8b005db5f57556fb96dfd98fbccfab84'
api = 'http://www.tuling123.com/openapi/api?key=' + key + '&info='
while True:
info = raw_input('我: ')
request = api + info
response = getHtml(request)
dic_json = json.loads(response)
print '机器人: '.decode('utf-8') + dic_json['text']
相关文章推荐
- python 调用图灵机器人api实现简单的人机交互
- python--RPC调用简单实现
- 用python的wxpython模块实现一个简单的与用户可以交互计算器
- C语言调用mysql数据库API实现简单的mysql客户端的功能
- 【Python】调用百度REST API实现语音识别
- AngularJS+RestfulAPI+BasicAuth+Python/PHP/Node.JS来实现一个最简单的新闻管理后台
- C语言MD5加密算法的简单调用实现(另附:Java/Python/Shell/Golang方法)
- Python包装网页微信API并实现简单自动回复
- 【Python】调用WPS V9 API,实现PPT转PDF
- 【Python】调用百度REST API实现语音识别
- Python中实现远程调用(RPC、RMI)简单例子
- python调用c语言函数的一种简单实现方法
- Python中实现远程调用(RPC、RMI)简单例子
- python xmlrpc实现二进制文件传输的代码,简单的远程调用
- C#调用Win32 API,实现简单的IP地址修改
- Python中实现远程调用(RPC、RMI)简单例子
- 调用Google的API实现简单的翻译功能
- python调用zabbix api 实现主机添加等功能
- 【实现&调用】实现可被简单调用的python函数
- python调用c语言函数的一种简单实现方法