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

菜鸟真心求教,用web.py写用户注册时遇到数据存储问题了。

  •  
  •   paloalto · Jul 7, 2012 · 3758 views
    This topic created in 5193 days ago, the information mentioned may be changed or developed.
    菜鸟一个,代码完全是照着教程上来的。

    class SignupHandler:
    def GET(self):
    f = register_form()
    return render.signup(f)

    def POST(self):
    f = register_form()
    name = web.input(name = "username")
    pwd = web.input(name = "password")
    if not f.validates():
    return render.signup(f)
    else:
    sequence_id = db.insert('userAuth', username = name, password = pwd, joindate = web.SQLLiteral("NOW()"), ipaddress = "111.1.1.1", lastactivity = web.SQLLiteral("NOW()"))
    raise web.seeother('/welcome')


    结果发现mysql里的数据变成了这样:



    谁能教教我怎么把用户输入的文本存到mysql里啊?

    ps:用户注册、登录时的cookie啊session啊什么的我先不管了,现在只要能正常存储数据就是迈了一大步,T^T。
    2 replies  •  2015-06-03 01:30:05 +08:00
    paloalto
        1
    paloalto  
    OP
       Jul 7, 2012
    哈哈哈哈,我自己解决了!

    原来是这么写:
    name = web.input().username
    pwd = web.input().password
    mliml
        2
    mliml  
       Jun 3, 2015
    @paloalto
    hello,我现在也在写web.py 用户系统,只不过数据库用的是 sqlite3 ,想问下您还有没有当时写的代码可以参考下呢?本人是个菜鸟,写代码写得一头雾水。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2644 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 03:32 · PVG 11:32 · LAX 20:32 · JFK 23:32
    ♥ Do have faith in what you're doing.