推荐学习书目
› 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
hititan
V2EX  ›  Python

requests.post 提交数据的问题,请指教

  •  
  •   hititan · Aug 29, 2017 · 3427 views
    This topic created in 3330 days ago, the information mentioned may be changed or developed.
    小弟不才,请大家告知,非常感谢,如下。
    在 html 里代码 1:
    <div class="input-red">
    <input type="number" name="math_word" class="form-red2" orders="请输入 20--50 之间的金额">
    </div>

    在 html 里代码 2:
    <div class="input-yellow">
    <input type="text" name="math_word" class="form-yellow2" orders="请输入问题的正确答案">
    </div>
    ====================
    想用 python 的 requests.post 里提交数据:
    answer=raw_input("填入正确的")
    data={"math_word":answer}
    -------------------------------------------
    请问在 html 里的数据类型会影响我的数据提交吗?
    比如<input type="number"和<input type="text"
    如果有影响,请问需要在<input type="number"这个数据类型下把 raw_input 获得的字符串转为 int 吗?
    3 replies  •  2017-08-30 00:50:13 +08:00
    phy25
        1
    phy25  
       Aug 29, 2017   ❤️ 2
    不影响,input:type 只是给浏览器提示 input 该显示成什么样,上传的数据都是 string,这个 type 不会进到 POST 的 data 里;到了服务器之后的类型变换都是服务器自己干的。
    hititan
        2
    hititan  
    OP
       Aug 30, 2017
    哦,明白了,非常感谢你的回答,这对我非常有用,再次感谢你!!!
    CEBBCAT
        3
    CEBBCAT  
       Aug 30, 2017 via Android   ❤️ 1
    小提示一下:有专门的感谢按钮的,但单发一层来感谢也是很棒,就是忘记 @ 他了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   6354 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 03:13 · PVG 11:13 · LAX 20:13 · JFK 23:13
    ♥ Do have faith in what you're doing.