成品
代码
import requests
class ChatRebot(object):
def __init__(self, content):
self.content = content
def chat(self):
url_api = "http://api.qingyunke.com/api.php?key=free&appid=0&msg=" + self.content
r = requests.get(url_api)
print(eval(r.text)['content'])
if __name__ == "__main__":
print("=====欢迎来到聊天机器人=====")
while True:
myContent = input(">>>")
chatRebot = ChatRebot(myContent)
chatRebot.chat()
机器人的api接口为青云客智能聊天机器人API
欢迎加入 网络资源共享群:695650348