摘要: 在一个Web App中,所有数据,包括用户信息、发布的日志、评论等,都存储在数据库中。在awesome-python-app中,我们选择MySQL作为数据库。Web App里面有很多地方都要访问数据库。访问数据库需要创建数据库连接、游标对象,然后执行SQL语句,最后处理异常,清理资源。这些访问数据库... 阅读全文
posted @ 2014-10-05 23:18 wuhn 阅读(859) 评论(0) 推荐(0) 编辑
摘要: 在python用import或者from...import来导入相应的模块。模块其实就是一些函数和类的集合文件,它能实现一些相应的功能,当我们需要使用这些功能的时候,直接把相应的模块导入到我们的程序中,我们就可以使用了。这类似于C语言中的include头文件,Python中我们用import导入我们... 阅读全文
posted @ 2014-10-05 22:40 wuhn 阅读(419) 评论(0) 推荐(0) 编辑
摘要: 搭建开发环境首先,确认系统安装的Python版本是2.7.x:$ python --versionPython 2.7.5然后,安装开发Web App需要的第三方库:前端模板引擎jinja2:$ easy_install jinja2MySQL 5.x数据库,从官方网站下载并安装,安装完毕后,请务必... 阅读全文
posted @ 2014-10-05 18:00 wuhn 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 用Python写一个真正的Web App!目标我们设定的实战目标是一个Blog网站,包含日志、用户和评论3大部分。比如webpy.org上就提供了一个Blog的例子,目测也就100行代码。我们要写出用户真正看得上眼的页面,首页长得像这样:评论区:还有极其强大的后台管理页面:项目名称必须是高端大气上档... 阅读全文
posted @ 2014-10-05 17:57 wuhn 阅读(537) 评论(0) 推荐(0) 编辑
摘要: Python 里面的编码和解码也就是 unicode 和 str 这两种形式的相互转化。编码是 unicode -> str,相反的,解码就是 str -> unicode。剩下的问题就是确定何时需要进行编码或者解码了.关于文件开头的"编码指示",也就是 # -*- coding: -*- 这个语句... 阅读全文
posted @ 2014-10-05 17:34 wuhn 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 字符串是要用引号(双引号,单引号,多行用三个引号)引起来TypeError: not enough arguments for format stringyou have to specify multiple arguments as tuple, egprint "%d %s of beer o... 阅读全文
posted @ 2014-10-05 17:29 wuhn 阅读(2422) 评论(0) 推荐(0) 编辑
摘要: You’re excited; your client is excited. All is well. You’ve just launched the client’slatest website, and it’s fantastic. You’ve put in hours of sweat... 阅读全文
posted @ 2014-10-05 13:28 wuhn 阅读(259) 评论(0) 推荐(0) 编辑
摘要: “Programs are meant to be read by humans and only incidentally(顺便;偶然地;附带地) for computers to execute.” —Donald KnuthWhen a team is brought together(被放在... 阅读全文
posted @ 2014-10-05 13:08 wuhn 阅读(191) 评论(0) 推荐(0) 编辑
摘要: JQuery的extend扩展方法: Jquery的扩展方法extend是我们在写插件的过程中常用的方法,该方法有一些重载原型,在此,我们一起去了解了解。一、Jquery的扩展方法原型是: extend(dest,src1,src2,src3...); 它的含义是将src1,src2,src3...... 阅读全文
posted @ 2014-10-05 03:04 wuhn 阅读(165) 评论(0) 推荐(0) 编辑
摘要: object type.html:26undefined type.html:27null type.html:28undefined type.html:29undefined type.html:30undefined 阅读全文
posted @ 2014-10-05 02:45 wuhn 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2014-10-05 02:25 wuhn 阅读(440) 评论(0) 推荐(0) 编辑
摘要: 今天遇到一个 IE7 下 JSON.parse 失败的问题。经过排查发现:服务端某个配置文件编码是UTF-8 + BOM,输出的字符串最开始包含了 BOM 字符,不是合法的 JSON。IE7 不支持原生 JSON,我们项目中使用的是json2.js,但解析不了开头有 BOM 字符的 JSON 不是 ... 阅读全文
posted @ 2014-10-05 02:13 wuhn 阅读(757) 评论(0) 推荐(0) 编辑
摘要: TypesEquality and ComparisonsJavaScript has two different ways of comparing the values of objects for equality.The Equality OperatorThe equality opera... 阅读全文
posted @ 2014-10-05 01:04 wuhn 阅读(247) 评论(0) 推荐(0) 编辑
摘要: ObjectsObject Usage and PropertiesEverything in JavaScript acts like an object, with the only two exceptions beingnullandundefined.false.toString(); /... 阅读全文
posted @ 2014-10-05 00:49 wuhn 阅读(392) 评论(0) 推荐(0) 编辑
摘要: Although JavaScript is very powerful, the language’s fundamentals do not have a very steep learning curve. Prior to the explosion of web applications,... 阅读全文
posted @ 2014-10-05 00:27 wuhn 阅读(322) 评论(0) 推荐(0) 编辑