`
文章列表
引用Mutability Difference: String is immutable, if you try to alter their values, another object gets created, whereasStringBuffer and StringBuilder are mutable so they can change their values. Thread-Safety Difference: The difference between StringBuffer and StringBuilder is that StringBuffer is thre ...
A B-tree index can be used for column comparisons in expressions that use the =, >, >=, <, <=, or BETWEEN operators. 1、The index also can be used for LIKE comparisons if the argument to LIKE is a constant string that does not start with a wildcard character. 2、Supports equality and range ...
引用Help on built-in function range in module __builtin__: range(...)     range([start,] stop[, step]) -> list of integers        Return a list containing an arithmetic progression of integers.     range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.     When step is given, it spe ...

python class

引用类是创建新对象类型的机制。 类定义了一组属性,这些属性与一组叫做实例的对象相关且由其共享。 类通常是由函数、变量和计算出的属性组成的集合。 类中最常用的就是构造方法和析构方法。 构造方法__init__(self,....)在 ...
CSS doesn't care,But Javascript cares. 引用 ID's are unique. Each element can only have only one ID. Each page can have only one element with that ID Classes are NOT unique You can use the same class on multiple elements. You can use multiple classes on the same element. id是唯一的,class是可以复用的。 web标准中不允 ...
网上查了下 意思是说你命名的文件名不能和lib重名,这样会导致import是你命名的文件。 于是我改了文件的名字 但是依然还是 AttributeError: 'module' object has no attribute 只好打印下dir下这个模块 发现还是原来的文件里面包含的东东 于是ls 项目目录 发现原来的文件的pyc还在,删掉就ok了。 大致就这样。

python string

如果这就是字符串,这本来就是字符串 首先看下字符串的方法 >>> dir(str) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', ...

python tips

1、enum #!/usr/bin/env python # -*- coding:utf-8 -*- def enum(**enums): return type('Enum', (), enums) Gender = enum(MALE=0,FEMALE=1) print Gender.MALE print Gender.FEMALE 2、检查字符串是否是number s='123456789' s.isdigit()#return True 3、list取交集 s=[1,2,3] w=[2,3,4] list(set(s).intersectio ...

python decorators

Contains: 1、decorators 2、functools 首先我们看下tornado中使用的装饰器 1、@tornado.web.authenticated 引用Decorate methods with this to require that the user be logged in. def authenticated(method): """Decorate methods with this to require that the user be logged in.""" @fun ...

python closures

Closure:如果在一个内部函数里,对在外部作用域(但不是在全局作用域)的变量进行引用,那么内部函数就被认为是闭包(closure)。它只不过是个"内层"的函数,由一个名字(变量)来指代,而这个名字(变量)对于“外层”包含它的函数而言,是本地变量。 demo: #-*-coding:utf-8-*- class Employee(object): def __init__(self,is_manager=False,salary=1000): self.is_manager = is_manager self.sa ...
1、filter(function,iterable) 引用Construct a list from those elements of iterable for which function returns true. iterable may be either a sequence, a container which supports iteration, or an iterator. If iterable is a string or a tuple, the result also has that type; otherwise it is always a list. If ...
Contains: __new__: 创建对象时调用,返回当前对象的一个实例 __init__:创建完成对象后调用,对当前对象的实例的一些初始化,无返回值 __call__: 一、__init__通过此方法我们可以顶一个对象的初始操作。 但是当我新建一个类的实例的时候,__init__并不是第一个被调用的,实际上,还有一个叫做__new__的方法,来构造这个实例。然后在给开始创建的初始化函数传递参数。 二、__new__        @staticmethod # known case of __new__ def __new__(cls, *more): # ...
Contains: 1、select 2、poll I/O复用模型使用在下列网络应用场合: 1、当客户处理多个FD时,必须使用I/O复用。 2、一个客户同事处理多个套接字是可能的。 3、如果一个TCP服务器处理多个socket。 4、如果一个服务器处理多个协议。 ...
自豪地使用dir和help. Python 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> dir ...

IO 模型

    博客分类:
  • Unix
Unix下可用的5种I/O模型: 1、阻塞式IO 2、非阻塞式I/O 3、I/O复用(select和poll) 4、信号驱动式(SIGIO) 5、异步I/O 一、阻塞式I/O模型 难道这个是传说中的一条道跑到黑? 二、非阻塞式I/O模型 相当于网上订票,不停的刷页面,看有余票没?没有的话不停地刷,刷到有票开始订购。这比喻不知道合适不? 进程把一个套接字设置成非阻塞是在通知内核:当所请求的I/O操作非得把本进程投入睡眠才能完成时,不要使本线程睡眠,而是返回一次错误。 当一个应用进程像这样对一个非阻塞描述符循环调用recvfrom时,我们称之为轮询。应用程序持续轮训内核,以查看某个操作是否就绪 ...
Global site tag (gtag.js) - Google Analytics