4.4. Static Fields and MethodsIn all sample programs that you have seen, the main method is tagged with the static modifier. We are now ready to discuss the meaning of this modifier.4.4.1. Static Fields(静态域)If you define a field as static, then there…
djiango在数据库这方式自己实现了orm(object relationship mapping 对象关系模型映射).这个主要是用到python 元类这一 项python中的高级技术来实现的. class ModelBase(type): def __new__(cls,name,bases,attrs): # ..... pass pass class Model(metaclass=ModelBase): pass # 在这之后所有的用户自定义模型都继承自Model类 class Per…
PMD错误 Avoid autogenerated methods to access private fields and methods of inner / outer classes 样例 public class Test { public static void main(final String[] args) { //code } public void test(){ Executors.newSingleThreadExecutor().execute(new Thread(…
Despite the common belief it is actually possible to access private fields and methods of other classes via Java Reflection. It is not even that difficult. This can be very handy during unit testing. This text will show you how. Note: This only works…
Django中的常用字段类型 1. 数值型 以下都是数值相关的,比如AutoField,它在MySQL中的类型为int(11),而BooleanField在MySQL中对应的类型是tinyint(1) AutoField int(11) 自增主键,Django Model默认提供,可以被重写.它的完整定义是id=models.AutoField(primary_key=True) BooleanField tinyint(1) 布尔类型字段,一般用于记录状态标记 DecimalField dec…
__exact        精确等于 like 'aaa' __iexact    精确等于 忽略大小写 ilike 'aaa' __contains    包含 like '%aaa%' __icontains    包含 忽略大小写 ilike '%aaa%',但是对于sqlite来说,contains的作用效果等同于icontains. __gt    大于 __gte    大于等于 __lt    小于 __lte    小于等于 __in     存在于一个list范围内 __st…
搞清楚datetime.datetime和datetime.date模块 他们两个的格式区别 datetime模块 In [1]: from datetime import datetime In [2]: datetime.now() Out[2]: datetime.datetime(2018, 11, 19, 9, 30, 34, 795738) In [3]: print(datetime.now()) 2018-11-19 09:30:40.604522 date模块 In [1]:…
<1> CharField #字符串字段, 用于较短的字符串. #CharField 要求必须有一个参数 maxlength, 用于从数据库层和Django校验层限制该字段所允许的最大字符数. <2> IntegerField #用于保存一个整数. <3> FloatField # 一个浮点数. 必须 提供两个参数: # # 参数 描述 # max_digits 总位数(不包括小数点和符号) # decimal_places 小数位数 # 举例来说, 要保存最大值为 9…
大部分内容参考自http://wrongwaycn.github.io/django11/topics/db/models/index.html#topics-db-models ,内容是django1.0的中文翻译. 个人根据django1.5的英文文档做了部分修改和添加. 字段类型(Field types) AutoField 它是一个根据 ID 自增长的 IntegerField 字段.通常,你不必直接使用该字段.如果你没在别的字段上指定主 键,Django 就会自动添加主键字段. Big…
方法是与某些特定类型相关联的函数.类.结构体.枚举都能够定义实例方法:实例方法为给定类型的实例封装了详细的任务与功能.类.结构体.枚举也能够定义类型方法:类型方法与类型本身相关联.类型方法与 Objective-C 中的类方法(class methods)相似. 结构体和枚举可以定义方法是 Swift 与 C/Objective-C 的主要差别之中的一个.在 Objective-C 中,类是唯一能定义方法的类型.但在 Swift 中,你不仅能选择是否要定义一个类/结构体/枚举,还能灵活的在你创建…