V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2018-07-30 16:27:09 +08:00 · 2434 次点击
    这是一个创建于 2095 天前的主题,其中的信息可能已经有所发展或是发生改变。
    10 条回复    2018-07-30 17:38:45 +08:00
    hicdn
        1
    hicdn  
       2018-07-30 16:30:34 +08:00
    data 是 str,param 是 dict
    param = {'a':1, 'b':2}
    data = 'a=1&b=2'
    KeatingSmith
        2
    KeatingSmith  
       2018-07-30 17:14:42 +08:00
    你可以这样理解,

    param 出现在 URL 地址上,

    data 不出现。
    bestehen
        3
    bestehen  
    OP
       2018-07-30 17:18:37 +08:00
    @KeatingSmith 出现在 url 地址上直接 get 不就可以了
    bestehen
        4
    bestehen  
    OP
       2018-07-30 17:23:39 +08:00
    @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  
       2018-07-30 17:27:22 +08:00
    params 的内容会带在 url 后面,作为 query string, 比如 https://www.baidu.com?xxx=yyy&aaa=bbb
    misaka19000
        6
    misaka19000  
       2018-07-30 17:29:55 +08:00
    能用搜索引擎搜索到的问题为什么要提个问题呢?

    https://stackoverflow.com/a/24535938/4614538
    pcdRob
        7
    pcdRob  
       2018-07-30 17:30:27 +08:00
    @hicdn params 是往 url 后面添加参数。
    Marmot
        8
    Marmot  
       2018-07-30 17:31:27 +08:00
    param: url 参数
    data: 表单
    json: json
    都传字典进去
    RyougiShiki
        9
    RyougiShiki  
       2018-07-30 17:32:47 +08:00
    params 是 url ?后那种; data 是 form 表单、file 类,在请求的 body 中。
    hicdn
        10
    hicdn  
       2018-07-30 17:38:45 +08:00
    @pcdRob 多谢指正。

    @bestehen 你的问题 @Marmot 说的很清楚。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2761 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:48 · PVG 23:48 · LAX 08:48 · JFK 11:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.