大部分的异常都继承自Exception这个类(而这个类有继承自BaseException这个类) 常见的异常 ValueError TypeError IndexError 抛出一个异常 下面这个类的作用是:添加偶数到列表中去. # 添加偶数到列表中:这个类继承了内置的list对象 class EvenOnly(list): def append(self, integer): # If the integer is not a int type, raise a TypeError if no
PHP date 格式化一个本地时间/日期 date (PHP 4, PHP 5) date — 格式化一个本地时间/日期 说明 string date ( string $format [, int $timestamp ] ) 返回将整数 timestamp 按照给定的格式字串而产生的字符串.如果没有给出时间戳则使用本地当前时间.换句话说,timestamp 是可选的,默认值为 time(). Tip 自 PHP 5.1.1 起有几个有用的常量可用作标准的日期/时间格式来指定 format
python每次处理一个字符的三种方法 a_string = "abccdea" print 'the first' for c in a_string: print ord(c)+1 print "the second" result = [ord(c)+1 for c in a_string] print result print "the thrid" def do_something(c): return ord(c)+1 result