推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
bestehen
V2EX  ›  Python

Python post 请求参数的问题

  •  
  •   bestehen · Jul 30, 2018 · 3139 views
    This topic created in 2914 days ago, the information mentioned may be changed or developed.
    10 replies    2018-07-30 17:38:45 +08:00
    hicdn
        1
    hicdn  
       Jul 30, 2018
    data 是 str,param 是 dict
    param = {'a':1, 'b':2}
    data = 'a=1&b=2'
    KeatingSmith
        2
    KeatingSmith  
       Jul 30, 2018
    你可以这样理解,

    param 出现在 URL 地址上,

    data 不出现。
    bestehen
        3
    bestehen  
    OP
       Jul 30, 2018
    @KeatingSmith 出现在 url 地址上直接 get 不就可以了
    bestehen
        4
    bestehen  
    OP
       Jul 30, 2018
    @hicdn
    一个网站的 Form_data post 参数是这样的,那我是传 Data 还是 param ?因为你这样看也不知道是 dict 还是 str
    page: 1
    num: 50
    w:
    ptype: qmp_pc
    version: 2.0
    unionid: ETXncbCRyisjw/hr0zeTaonhpvkz/81ntwbBWAKYE4wdmhbtHCwxkjwb+0gjVdRzeJWqqIs6kiQsM8IbOYgM5A==
    jtype: vip
    time_token: 1532254367533
    welkinzh
        5
    welkinzh  
       Jul 30, 2018
    params 的内容会带在 url 后面,作为 query string, 比如 https://www.baidu.com?xxx=yyy&aaa=bbb
    misaka19000
        6
    misaka19000  
       Jul 30, 2018
    能用搜索引擎搜索到的问题为什么要提个问题呢?

    https://stackoverflow.com/a/24535938/4614538
    pcdRob
        7
    pcdRob  
       Jul 30, 2018
    @hicdn params 是往 url 后面添加参数。
    5oiR5piv5YK76YC8
        8
    5oiR5piv5YK76YC8  
       Jul 30, 2018
    param: url 参数
    data: 表单
    json: json
    都传字典进去
    RyougiShiki
        9
    RyougiShiki  
       Jul 30, 2018
    params 是 url ?后那种; data 是 form 表单、file 类,在请求的 body 中。
    hicdn
        10
    hicdn  
       Jul 30, 2018
    @pcdRob 多谢指正。

    @bestehen 你的问题 @Marmot 说的很清楚。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3175 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 64ms · UTC 12:16 · PVG 20:16 · LAX 05:16 · JFK 08:16
    ♥ Do have faith in what you're doing.