此处是开玩笑的,真的要达到星期五暂时还不行,用图灵机器人简单写一个对话机器人
# -*- coding: utf-8 -*-
import urllib
import json
import sys,locale
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
if __name__ == '__main__':
key = '图灵机器人申请的KEY'
api = 'http://www.tuling123.com/openapi/api?key=' + key + '&info='
while True:
info = raw_input('我: ').strip().decode(sys.stdin.encoding or locale.getpreferredencoding(Ture)).encode('utf-8')
request = api + info
response = getHtml(request)
dic_json = json.loads(response)
print '星期五:'.decode('utf-8') + dic_json['text']