猫史档案馆


【Python作品分享】图灵机器人

用户:局域网唤醒WakeonLan局域网唤醒WakeonLan查看:0 回复:1 评论:0 创建时间:2020-04-06T13:43:34


【作品展示】

center_image

 

【作品介绍】

全新图灵机器人,满足任何要求,直接聊天即可。

 

【作品源代码】

import requests
import json
url = 'http://openapi.tuling123.com/openapi/api/v2'
city = input('请输入您的城市:')
while True:
    a = input('我:')
    if a == 'q':
        break
    req = {
        "reqType": 0,
        "perception": {
            "inputText": {
                "text": a
            },
            "inputImage": {
                "url": "imageUrl"
            },
            "selfInfo": {
                "location": {
                    "city": city,
                }
            }
        },
        "userInfo": {
            "apiKey": "628cf3dee0524dea995c2896bd10468b",
            "userId": "575289"
        }
    }
    req = json.dumps(req).encode('utf8')
    post = requests.post(url, data=req, headers={
                         'content-type': 'application/json'})
    r = post.text
    r = r.encode('utf8')
    r = json.loads(r)
    text = r['results'][0]['values']['text']
    print('机器人:', text)

  

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
ray_crazyray_crazy

center_image

点赞1


评论