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
hititan
V2EX  ›  Python

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

  •  
  •   hititan · 2017-08-29 22:28:58 +08:00 · 2291 次点击
    这是一个创建于 2431 天前的主题,其中的信息可能已经有所发展或是发生改变。
    小弟不才,请大家告知,非常感谢,如下。
    在 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 条回复    2017-08-30 00:50:13 +08:00
    phy25
        1
    phy25  
       2017-08-29 23:59:42 +08:00   ❤️ 2
    不影响,input:type 只是给浏览器提示 input 该显示成什么样,上传的数据都是 string,这个 type 不会进到 POST 的 data 里;到了服务器之后的类型变换都是服务器自己干的。
    hititan
        2
    hititan  
    OP
       2017-08-30 00:46:57 +08:00
    哦,明白了,非常感谢你的回答,这对我非常有用,再次感谢你!!!
    CEBBCAT
        3
    CEBBCAT  
       2017-08-30 00:50:13 +08:00 via Android   ❤️ 1
    小提示一下:有专门的感谢按钮的,但单发一层来感谢也是很棒,就是忘记 @ 他了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5647 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:25 · PVG 11:25 · LAX 20:25 · JFK 23:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.