我按照这里的教程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来说很新
最佳答案
某处,使用参数’19 02:39:09’调用int(). int()无法处理冒号或空格.
>>> 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
>>>
希望这可以帮助.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。