• python http


    数据传输

                data:
                    request.post(
                        url='xx',
                        data={'k1':'v1,'k2':'v2'}
                    )
                    #数据:  POST /  http1.1
    ....
    
    k1=v1&k2=v2
                    
                    
                    request.post(
                        url='xx',
                        data=json.dumps({'k1':'v1,'k2':'v2'})
                    )
                    #数据:  POST /  http1.1
    ....
    
    {'k1':'v1,'k2':'v2'}
                    
                    request.post(
                        url='xx',
                        data=b'asdfasdf'
                    )
                    #数据:  POST /  http1.1
    ....
    
    'asdfasdf'
                json:
                    request.post(
                        url='xx',
                        json={'k1':'v1,'k2':'v2'}
                    )
                    #数据:  POST /  http1.1
    Content-type:application/json....
    
    {'k1':'v1,'k2':'v2'}
        
                问题:
                    同时:POST请求发数据
                    
                    django:获取不到值?request.POST 
                    
                    发送数据格式:
                        方式一:
                            request.post(
                                url='xx',
                                data={'k1':'v1,'k2':'v2'}
                            )
                            #数据:  POST /  http1.1
    Content-type:urlencode-form.......
    
    k1=v1&k2=v2
            
                            
                            request.POST必然可以获取到值。
                                - content-type: urlencode-form
                                - 数据格式:k1=v1&k2=v2
        
                        方式二:
                            request.post(
                                url='xx',
                                json={'k1':'v1,'k2':'v2'}
                            )
                            #数据:  POST /  http1.1
    Content-type:application/json....
    
    {'k1':'v1,'k2':'v2'}
                            request.body 
                                字节 = {'k1':'v1,'k2':'v2'}
                                字节转换字符串
                                反序列化字符串 -> 字典 
                            
                            request.POST必然不可以获取到值。
                                - content-type: urlencode-form
                                - 数据格式:k1=v1&k2=v2
                            
                    
                知识点:
                    chrome->
                        Form Data:
                            phone=861513125555&password=12312312312&oneMonth=1
                            
                            reqeusts.post(
                                url=url,
                                data={
                                    phone:123123123123,
                                    password:asdfasdf
                                }
                            )
                        
                        Request Payload:
                            {"BaseRequest":{"Uin":981579400,"Sid":"zWvteTWqBop4heoT","Skey":"@crypt_2ccf8ab9_a710cf413c932e201987599558063c8e","DeviceID":"e358217921593270"},"Msg":{"Type":1,"Content":"test","FromUserName":"@60eef3f2d212721fda0aae891115aa7a","ToUserName":"@@6a5403f510a3192454ed1afebd78ec6033d5057c9038d7b943b201f0a74987d4","LocalID":"15300708105840758","ClientMsgId":"15300708105840758"},"Scene":0}
                        
                            reqeusts.post(
                                url=url,
                                json={
                                    phone:123123123123,
                                    password:asdfasdf
                                }
                            )
                            
                            reqeusts.post(
                                url=url,
                                data=bytes(json.dumps({
                                    phone:123123123123,
                                    password:asdfasdf
                                }),encoding=utf-8)
                            )
        
        
                    firefox:
                        表单数据:
                            
                        JSON:
    View Code
  • 相关阅读:
    初识ACM——幸好不用排序
    初识ACM——中文的信仰
    初识ACM——中文的信仰
    初识ACM——九九乘法表
    初识ACM——九九乘法表
    JavaScript 10 作用域
    JavaScript 09 简单的加法计算器
    JavaScript 08 函数
    JavaScript 07 类型转换
    JavaScript 06 基本数据类型
  • 原文地址:https://www.cnblogs.com/huay/p/11626680.html
Copyright © 2020-2023  润新知