Skip to content

Instantly share code, notes, and snippets.

@sko00o
Created November 27, 2017 16:50
Show Gist options
  • Save sko00o/cc33abacd518319af37b553fae2e5467 to your computer and use it in GitHub Desktop.
Save sko00o/cc33abacd518319af37b553fae2e5467 to your computer and use it in GitHub Desktop.
ChatWithRobot.py
import requests
import json
# 你无聊的时候可以找个机器人聊天啊……
def talkwithrobot(str):
say = str
via = 'http://op.juhe.cn/robot/index?info='+say+'&key=df2c3195b69b9c9fce3678698edc80a2'
res = requests.request('GET',via).json()
res2 = res['result']['text']
return res2
if __name__ == '__main__':
print('say something, type "end" to exit.')
while True:
str = input('Me:\t')
if str == 'end':
break
print('RB:\t'+talkwithrobot(str))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment