猫史档案馆


从Python官网转了一圈回来,我XX了

用户:萌新一个萌新一个查看:16 回复:11 评论:16 创建时间:2020-08-09T11:35:49


从Python官网转了一圈回来,我发现我什么也不是,就是个XX

好受打击啊...

(还是拼积木比较容易。。。)


回复

上一页1 页 / 共 1下一页
_someone__someone_

沙发

点赞1


评论


_someone__someone_

我刚才在海龟写了300000+行代码center_image

点赞0


评论


yunyunyunyun

# coding=utf-8
import json
import urllib.request


api_url = "http://openapi.tuling123.com/openapi/api/v2"
text_input = input('我:')

req = {
    "perception":
    {
        "inputText":
        {
            "text": text_input
        },

        "selfInfo":
        {
            "location":
            {
                "city": "上海",
                "province": "上海",
                "street": "文汇路"
            }
        }
    },

    "userInfo": 
    {
        "apiKey": "eaf3fa76e15喵eb5ae7ca889721997f6",
        "userId": "OnlyUseAlphabet"
    }
}
# print(req)
# 将字典格式的req编码为utf8
req = json.dumps(req).encode('utf8')
# print(req)

http_post = urllib.request.Request(api_url, data=req, headers={'content-type': 'application/json'})
response = urllib.request.urlopen(http_post)
response_str = response.read().decode('utf8')
# print(response_str)
response_dic = json.loads(response_str)
# print(response_dic)

intent_code = response_dic['intent']['code']
results_text = response_dic['results'][0]['values']['text']
print('机器人:',results_text)

点赞0


评论


yunyunyunyun

这才叫代码

 

点赞0


评论


wrmdcxywrmdcxy

如何快速地写300万行代码:

with open("300M.py",'w') as f:
    for x in range(100):# 这是为了防止内存爆掉
        f.write("pass\n"*30000)

点赞0


评论


_Rise__Rise_

事实证明,学编程最难的一步是配置

点赞2


评论


萌新一个萌新一个

我是刚转入海龟的萌新

点赞1


评论


萌新一个萌新一个

就发了一条关于Python的帖子,没想到这么热门...

比积木编程还热门

点赞1


评论


萌新一个萌新一个

这这这

点赞0


评论


萌新一个萌新一个

都到第二行了

点赞0


评论


萌新一个萌新一个

吧  

点赞1


评论