聊天机器人

from time import sleep
import requests
s = input("请主人输入话题:")
while True:
    resp = requests.post("http://www.tuling123.com/openapi/api",data={"key": "4fede3c4384846b9a7d0456a5e1e2943", "info": s, })
    resp = resp.json()
    sleep(1)
    print('小鱼:', resp['text'])
    s = resp['text']
    resp = requests.get("http://api.qingyunke.com/api.php", {'key': 'free', 'appid': 0, 'msg': s})
    resp.encoding = 'utf8'
    resp = resp.json()
    sleep(1)
    print('菲菲:', resp['content'])

请主人输入话题:hello
小鱼: 你好
菲菲: 我很好,你呢,你怎么样
小鱼: 啦啦啦,每天都是好心情

猜你喜欢

转载自blog.csdn.net/weixin_33595571/article/details/84969019