Created
November 27, 2017 16:50
-
-
Save sko00o/cc33abacd518319af37b553fae2e5467 to your computer and use it in GitHub Desktop.
ChatWithRobot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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