[那些似懂非懂的细节]python3发http/https请求

python3自带的包用起来非常复杂,使用三方包Requests可以方便的发请求。

安装三方包

    pip3 install requests

发post请求

    # 向钉钉群发消息
    url = "https://oapi.dingtalk.com/robot/send?access_token=edd236299cd610ec989071f66e1abc5cb20c7ebd3613bd95a387b604fdb61e21000"
    headers = {"Content-type": "application/json"}
    paramsDic = {'msgtype': 'text',
                 'text': {'content':'我是打包机器人!'}}
    d = json.dumps(paramsDic)
    resp = requests.post(url,data=d,headers=headers)
    print(resp)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容