您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python – 使用sqlite的web.py todo列表int()的无效文字

5b51 2022/1/14 8:21:17 python 字数 3544 阅读 535 来源 www.jb51.cc/python

我按照这里的教程http://webpy.org/docs/0.3/tutorial然后环顾网页,找出如何使用sqlite的待办事项列表部分,发现这个http://kzar.co.uk/blog/view/web.py-tutorial-sqlite我无法通过此错误.我搜索过,没有一个我能找到的结果帮助我太多了.大多数人建议从括号中取出引号.错误<ty

概述

我按照这里的教程http://webpy.org/docs/0.3/tutorial然后环顾网页,找出如何使用sqlite的待办事项列表部分,发现这个http://kzar.co.uk/blog/view/web.py-tutorial-sqlite

我无法通过此错误.我搜索过,没有一个我能找到的结果帮助我太多了.大多数人建议从括号中取出引号.

错误


  

code.py

import web

render = web.template.render('templates/')

db = web.database(dbn='sqlite',db='testdb')

urls = (
    '/','index'
)

app = web.application(urls,globals())

class index:
    def GET(self):
        todos = db.select('todo')
        return render.index(todos)

if __name__ == "__main__": app.run()

模板/ index.html的

$def with (todos)

  

testbd

CREATE TABLE todo (id integer primary key,title text,created date,done boolean default 'f');
CREATE TRIGGER insert_todo_created after insert on todo
begin
update todo set created = datetime('Now')
where rowid = new.rowid;
end;

对web.py sqlite来说很新

>>> int('19 02:39:09')
Traceback (most recent call last):
  File "
  

我建议调用replace()来摆脱像这样的空格和冒号:

>>> date='19 02:39:09'
>>> date=date.replace(" ","")
>>> date
'1902:39:09'
>>> date=date.replace(":","")
>>> date
'19023909'
>>> int(date)  ## It works Now!
19023909
>>> 

希望这可以帮助.

总结

以上是编程之家为你收集整理的python – 使用sqlite的web.py todo列表int()的无效文字全部内容,希望文章能够帮你解决python – 使用sqlite的web.py todo列表int()的无效文字所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶