Python 一些内置函数的总结~~~~
1. type()
两种用法
a. 当传入参数为一个时,返回值为参数的类型
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 -- 可选,初始参数
Python 一些内置函数的总结~~~~的更多相关文章
- python基础-内置函数详解
一.内置函数(python3.x) 内置参数详解官方文档: https://docs.python.org/3/library/functions.html?highlight=built#ascii ...
- 如何查看Python的内置函数
经常调用的时候不知道python当前版本的内置函数是哪些,可以用下面的指令查看: C:\Users\Administrator>python Python 2.7.11 (v2.7.11:6d1 ...
- python_way,day3 集合、函数、三元运算、lambda、python的内置函数、字符转换、文件处理
python_way,day3 一.集合 二.函数 三.三元运算 四.lambda 五.python的内置函数 六.字符转换 七.文件处理 一.集合: 1.集合的特性: 特性:无序,不重复的序列 如果 ...
- python基础——内置函数
python基础--内置函数 一.内置函数(python3.x) 内置参数详解官方文档: https://docs.python.org/3/library/functions.html?highl ...
- Python的内置函数
python的内置函数一共有68个,下面将简单介绍各个函数的功能. abs() dict() help() min() setattr() all() dir() hex() next() slice ...
- python print()内置函数
啦啦啦啦啦啦,我又来了,学习任何东西都得坚持,我一定的好好加油!!! 今天来说说print()函数,前边我们已经用过好好多次啦,现在来学习哈吧!!! Python的内置函数,print() print ...
- Python入门-内置函数一
什么是内置函数?就是python给你提供的拿来直接用的函数,比如print,input等等,截止到python版本3.6.2 python一共提供了68个内置函数,他们就是python直接提供给我们的 ...
- Python 集合内置函数大全(非常全!)
Python集合内置函数操作大全 集合(s).方法名 等价符号 方法说明 s.issubset(t) s <= t 子集测试(允许不严格意义上的子集):s 中所有的元素都是 t 的成员 s ...
- Python字典内置函数和方法
Python字典内置函数和方法: 注:使用了 items.values.keys 返回的是可迭代对象,可以使用 list 转化为列表. len(字典名): 返回键的个数,即字典的长度 # len(字典 ...
- Python元组内置函数
Python元组内置函数: len(元组名): 返回元组长度 # len(元组名): # 返回元组长度 tuple_1 = (1,2,3,'a','b','c') print("tuple_ ...
随机推荐
- Android webview 写入cookie的解决方法以及一些属性设置
原文地址:https://www.2cto.com/kf/201703/616868.html Android webview 写入cookie的解决方法以及一些属性设置,webview怎么设置写入C ...
- SpringCloud学习成长之十四 服务注册(consul)
这篇文章主要介绍 spring cloud consul 组件,它是一个提供服务发现和配置的工具.consul具有分布式.高可用.高扩展性. 一.consul 简介 consul 具有以下性质: 服务 ...
- 使用idea创建简单的webservice服务
New project: 生成HelloWorld.wsdl: 配置好tomcat后还需要加入 Axis 的库: 启动后,访问http://localhost:8080/services: 点击He ...
- JAVA8中接口的一些新用法(springboot环境)
@Configuration public interface IAbstractConvertStrategy { CacheService getCacheService(); default b ...
- LeetCode_371. Sum of Two Integers
371. Sum of Two Integers Easy Calculate the sum of two integers a and b, but you are not allowed to ...
- HTML布局排版之制作个人网站的文章列表
文章列表.博文列表,一般是有文章名字和时间构成的,文章名字后面是时间,点击文章的名字,可进入该文章.为了美观,一般文章名字都有一定的最大字数限制,长宽对齐,等长宽的统一格式比较美观,这种用表格来做比较 ...
- 【Leetcode_easy】922. Sort Array By Parity II
problem 922. Sort Array By Parity II solution1: class Solution { public: vector<int> sortArray ...
- 【Leetcode_easy】872. Leaf-Similar Trees
problem 872. Leaf-Similar Trees 参考 1. Leetcode_easy_872. Leaf-Similar Trees; 完
- nodejs应用转换png,jpg,gif为webp图片格式
本博客列表缩略图在支持webp格式的浏览器下,使用的是webp格式图片,不支持webp图片下使用的是原图片(如png,gif,jpg等) webp使用指南,请参考 https://www.imqian ...
- 解决RedisDesktopManager连接不上redis问题
linux 下安装redis很简单,在此不做赘述 发现linux上启动redis,测试redis使用正常, 但使用RedisDesktopManager却连接不上,报错如下,报错信息显示:当前使用的P ...