1. type()

两种用法

a. 当传入参数为一个时,返回值为参数的类型

b. 当传入参数为三个时,type(name, bases, dict)
name: 类名
bases: 继承父类的元组,可继承也可不继承
dict: 构成类属性和方法的键值对(方法在外部定义,直接引用).
返回一个类对象
class TestBasic(object):
@staticmethod
def parent():
print "this is parent method" def child(self):
print "this is child method" test_property = {"name": "heihei", "child": child} Test = type("Test", (TestBasic,), test_property) test = Test() print test.name
test.child()
test.parent()

运行结果:

heihei
this is child method
this is parent method

2. reduce()

函数将一个数据集合(链表,元组等)中的所有数据进行下列操作:用传给 reduce 中的函数 function(有两个参数)先对集合中的第 1、2 个元素进行操作,得到的结果再与第三个数据用 function 函数运算,最后得到一个结果。 

reduce(function, iterable[, initializer])

参数:

  • function -- 函数,有两个参数
  • iterable -- 可迭代对象
  • initializer -- 可选,初始参数

最新文章

  1. web前端笔试选择题
  2. Codeforces Round #361 (Div. 2) B
  3. [转]理解HTTP幂等性
  4. HBase之show table
  5. LeetCode 【235. Lowest Common Ancestor of a Binary Search Tree】
  6. Java历史版本下载
  7. 树状数组的笔记√(hzwer blog)
  8. 页面上动态编译及执行java代码
  9. C++变量(C++变量定义、变量赋值、命名规则)
  10. MAC 命令行工具(Command Line Tools)安装
  11. 在win7/8/10鼠标右键添加“管理员取得所有权”
  12. Struts2框架(8)---Struts2的输入校验
  13. linux 基本使用命令
  14. haroopad 預覽區樣式
  15. (转)nginx uwsgi wsgi django 这些东西究竟是什么关系
  16. 从数据库中修改zabbix的验证方式 0 内置 1 LDAP 2 HTTP
  17. 页面滚动插件 better-scroll 的用法
  18. JDBC实例--工具类升级,使用Apache DBCP连接池重构DBUtility,让连接数据库更有效,更安全
  19. js简单正则表达式验证密码
  20. 北京Uber优步司机奖励政策(12月29日)

热门文章

  1. STM32---喜提点灯
  2. Win10安装Oracle Database 18c (18.3)
  3. 怎么改变wampserver默认的网站目录
  4. axios ajax框架 请求配置
  5. Win10利用CodeBlocks搭建Objective-C开发环境(一)
  6. console.log()和alert()的区别
  7. Appium移动自动化测试-----(七)Desired Capabilities
  8. synchrnized 和lock的区别
  9. Mysql 千万数据快速导入
  10. LeetCode 21. 合并两个有序链表(Merge Two Sorted Lists)