import urllib.request
import json
import string
while True:
target = r'http://api.qingyunke.com/api.php?key=free&appid=0&msg'
keyword = input("想聊点什么:")
if keyword =="exit":
print ("不聊算了,滚")
break
tmp =target + keyword
url = urllib.parse.quote(tmp, safe= string.printable)
page = urllib.requst.urlopena(url)
html = page.read().decode("utf-8")
res = json.loads(html)
print(res['content'])
对话聊天