摘要: 项目中经常用到日期的操作,包括日期的格式化。下面是几个比较常用的工具类。import java.text.SimpleDateFormat;import java.util.Date;import org.apache.commons.lang.time.DateFormatUtils;import... 阅读全文
posted @ 2015-09-01 16:20 nihousheng 阅读(475) 评论(0) 推荐(0) 编辑
摘要: public class Test{public static void main(String[] args){Integer i1 = 100;Integer i2 = 100;if(i1 == i2){System.out.println("i1==i2");}else{System.out.... 阅读全文
posted @ 2015-07-27 12:33 nihousheng 阅读(1675) 评论(0) 推荐(0) 编辑
摘要: 如果这是你第一次使用Django,你必须进行一些初始设置。即,您将需要自动生成一些代码,建立了Django项目。从命令行、cd进入一个目录,你想要存储您的代码,然后运行以下命令: django-admin startproject mysite这样就会在当前目录下创建一个为mysite的目录。在这... 阅读全文
posted @ 2015-06-08 18:20 nihousheng 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 在Python中流程控制if语句采用如下格式:if expression : statementelif expression : statementelif expression : statementelse : statement其中expression返回的是布尔类型的值:True或... 阅读全文
posted @ 2015-06-03 22:28 nihousheng 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 下面是一个新闻的模板:mysite/news/templates/news/year_archive.htmlmysite/news/templates/news/year_archive.html{% extends "base.html" %}{% block title %}Articles ... 阅读全文
posted @ 2015-06-03 17:25 nihousheng 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 字典dict: 字典其实就相当于java里面的Map,用来存储键值对的。其中存储的数据时无序的。 假如有这样的数据: t1=['name','age','sex'] t2=['tom',30,'male'] 通过zip(t1,t2)可以获取到这样的数据[('name','tom'),('a... 阅读全文
posted @ 2015-06-02 23:34 nihousheng 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 列表: list是一组有序项目的数据结构。 列表是可变类型的数据,列表用[]进行表示,包含了多个以","分隔的项目。1 list=[]2 type(list)3 //列表的操作方法有: list=['tom',30,'male'] 取值: 切片和索引 list[0] 输出tom ... 阅读全文
posted @ 2015-06-02 22:44 nihousheng 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 插播一下,先了解一下Python的数据类型,Python现有的数据类型有好多,最重要的有列表、元组、字典 列表:我觉得可以对应java中的数组 list=['physics', 'chemistry', 1997, 2000]; nums=[1, 3, 5, 7, 8,... 阅读全文
posted @ 2015-06-01 23:03 nihousheng 阅读(246) 评论(1) 推荐(0) 编辑
摘要: 在Python中想要输出一句话,如下 1 a='hello world' 2 print a 3 //打印出的是hello world 4 5 print 'hello \n world' 6 //打印出的是 7 //hello 8 //world 9 print '''hello10 ... 阅读全文
posted @ 2015-06-01 22:16 nihousheng 阅读(880) 评论(0) 推荐(0) 编辑
摘要: 请求解析一般都是通过请求的request获取一定参数,然后根据参数做一定业务逻辑判断,这其中可能包括查询数据库,然后将需要返回的数据封装成一个HttpResponse返回。 代码如下:这是一个简单的处理请求的函数,对应之前url映射的 url(r'^articles/([0-9]{4})/$'... 阅读全文
posted @ 2015-05-29 18:33 nihousheng 阅读(294) 评论(0) 推荐(0) 编辑