以MYSQL为例: (1)在model中定义两个数据表,食物信息和食物类别信息 class foodInfo(models.Model): food_id = models.AutoField(max_length=4) #自定义主键,不指定主键默认会生成一个名为‘ID’列的主键 food_name ...
分类:
数据库 时间:
2017-08-17 20:02:41
阅读次数:
253
采用django自带的Paginator功能 from django.core.paginator import Paginator food = foodInfo.objects.filter(food_name__contains=searchstr) pag = Paginator(food, ...
分类:
其他好文 时间:
2017-08-17 19:57:38
阅读次数:
138
一、协程函数 yield的用法: 1 # 例子1 2 # def chi(name): 3 # print('%s 开始上菜啦~'%name) 4 # cd=[] #菜单 5 # while True: 6 # food=yield cd 7 # cd.append(food) 8 # print( ...
分类:
编程语言 时间:
2017-08-03 16:06:05
阅读次数:
238
1.1 协程函数理解 协程函数就是使用了yield表达式形式的生成器 def eater(name): print("%s eat food" %name) while True: food = yield print("done") g = eater("gangdan") print(g) 结果 ...
分类:
编程语言 时间:
2017-07-31 11:45:59
阅读次数:
150
FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has ...
分类:
其他好文 时间:
2017-07-20 20:15:25
阅读次数:
178
一、概述 Python中支持多继承,也就是一个子类可以继承多个父类/基类。当一个调用一个自身没有定义的属性时,它是按照何种顺序去父类中寻找的呢?尤其是当众多父类中都包含有同名的属性,这就涉及到新式类 和 经典类的区别。 二、多继承 1 class Food(object): 2 3 def __in ...
分类:
其他好文 时间:
2017-07-17 22:08:30
阅读次数:
194
call和apply的区别: 在javascript中我们经常这样定义: 但是如果我们有一个对象whiteDog = {food:"bone"}, 我们不想对它重新定义say方法, 那么我们可以通过call或apply用blackCat的say方法: 就是调用的意思: blackCat.say.ca ...
digest /?da?d?est/: to change food that you have just eaten into substances that your body can use; or to understand new information, especially when ...
分类:
其他好文 时间:
2017-07-04 21:51:03
阅读次数:
442
1.做一个饲养员给动物喂食物的样例体现JAVA中的面向对象思想,接口(抽象类)的用处 package com.softeem.demo; /** *@authorleno *动物的接口 */ interface Animal { public void eat(Food food); } /** * ...
分类:
编程语言 时间:
2017-07-02 13:46:53
阅读次数:
216
We live in an age where food which used to take us hours to obtain can be delivered to your doorstep in under 30 minutes. Never in the history of mank ...
分类:
其他好文 时间:
2017-07-01 13:46:35
阅读次数:
156