内置函数的基本使用

abs的使用:

取绝对值

  1. abs
    print(abs(123))
    print(abs(-123))
  2.  
  3. result
    123
    123

all的使用:

循环参数,如果每个元素都为真的情况下,那么all的返回值为True:

  1. 假: 0 None "" [],(), {}
  2.  
  3. ret = all([True, True])
  4.  
  5. ret1 = all([True, False])
  6.  
  7. result:
  8.  
  9. True
  10.  
  11. False

any的使用:

只要有一个为True,则全部为True

  1. ret = any(None, "", [])
  2.  
  3. ret1 = any(None, "", 1)
  4.  
  5. result:
  6.  
  7. False
  8.  
  9. True

ascii的使用:

回去对象的类中,找到__repr__方法,找到该方法之后获取返回值

  1. class Foo:
  2.  
  3. def __repr__(self):
  4.  
  5. return "hello"
  6.  
  7. obj = Foo()
  8.  
  9. ret = ascii(obj )
  10.  
  11. 自动去对象(类)中找到 __repr__方法获取其返回值

bin的使用:

二进制

  1. ret = bin(11)
  2.  
  3. result:
  4.  
  5. 0b1011

oct的使用:

八进制

  1. ret = oct(14)
  2.  
  3. result:
  4.  
  5. 0o16

int的使用:

十进制

  1. ret = int(10)
  2.  
  3. result:
  4.  
  5. 10

hex的使用:

十六进制

  1. ret = hex(14)
  2.  
  3. result:
  4.  
  5. 0xe 0x:表示16进制 e 表示14

bool的使用:

判断真假,  True:真  ,  False:假,   把一个对象转换成bool值

  1. ret = bool(None)
  2.  
  3. ret = bool(1)
  4.  
  5. result:
  6.  
  7. False
  8.  
  9. True

bytearray的使用:

字节列表

列表元素是字节,

  1. bytes的使用:
  2.  
  3. 字节
  4.  
  5. bytes("xxx", encoding="utf-8")

callable的使用:

判断对象是否可被调用

  1. class Foo: #定义类
  2. pass
  3.  
  4. foo = Foo() # 生成Foo类实例
  5. print(callable(foo)) # 调用实例
  6. ret = callable(Foo) # 判断Foo类是否可被调用
  7. print(ret)
  8.  
  9. result
  10. False
  11. True

chr的使用:

给数字找到对应的字符

  1. ret = chr(65)
  2.  
  3. result:
  4.  
  5. A

ord的使用:

给字符找到对应的数字

  1. ret = ord("a")
  2.  
  3. result:
  4.  
  5. a

classmethod的使用:

修饰符

修饰符对应的函数不需要实例化,不需要self参数,但第一个参数需要时表示自身类的cls参数,可以来调用类的属性,类的方法,实例化对象等。

  1. class A(object):
  2. bar = 1
  3. def func(self):
  4. print("func")
  5. @classmethod
  6. def func2(cls):
  7. print("func2")
  8. print(cls.bar)
  9. cls().func() # 调用func方法
  10.  
  11. A.func2() # 不需要实例化
  12.  
  13. result
  14. func2
  15. 1
  16. func

compile的使用:

函数讲一个字符串编译为字节代码

  1. compile(source, filename, mode[, flags[, dont_inherit]])
  2.  
  3. 参数:
  4. source 字符串或者AST(Abstract Syntax Trees对象)
  5.  
  6. filename 代码文件名称,如果不是从文件读取代码则传递一些可辨认的值
  7.  
  8. mode 指定编译代码的种类,可指定: exec eval single
  9.  
  10. flags 变量作用域,局部命名空间,如果被提供,可以是任何映射对象。
  11.  
  12. flagsdont_inherit是用来控制编译源码时的标志
  1. str_for = "for i in range(1,10): print(i)"
  2. c = compile(str_for, '', 'exec') # 编译为字节代码对象
  3. print(c)
  4. print(exec(c))
  5.  
  6. result
  7. 1
  8. 2
  9. 3
  10. 4
  11. 5
  12. 6
  13. 7
  14. 8
  15. 9

complex的使用:

函数用于创建一个值为 real + image * j 的复数或者转化一个字符串或数为复数,如果第一个参数为字符串,则不需要指定第二个参数。

  1. 语法:
  2.  
  3. class complex([real ,[ image]])
  4.  
  5. 参数说明:
  6. real int, long, float或字符串
  7.  
  8. image intlongfloat
  1. ret1 = complex(1,2)
  2. print(ret1)
  3.  
  4. ret2 = complex(1)
  5. print(ret2)
  6.  
  7. ret3 = complex("")
  8. print(ret3)
  9.  
  10. ret4 = complex("1+2j")
  11. print(ret4)
  12.  
  13. result:返回一个复数
  14. (1+2j)
  15. (1+0j)
  16. (1+0j)
  17. (1+2j)

delattr的使用:

用于删除属性

  1. delattr(x, "foobar") 相等于 del x.foobar
  2.  
  3. 语法:
  4.  
  5. delattr(object, name)
  6.  
  7. 参数:
  8. object 对象
  9.  
  10. name 必须是当前对象的属性
  1. class DelClass:
  2. x = 10
  3. y = -5
  4. z = 0
  5.  
  6. obj = DelClass
  7. print("x", obj.x)
  8. print("y", obj.y)
  9. print("z", obj.z)
  10.  
  11. delattr(DelClass, 'z')
  12. print("x", obj.x)
  13. print("y", obj.y)
  14. print("报错", obj.z)
  15.  
  16. result
  17.  
  18. x 10
  19. y -5
  20. z 0
  21. x 10
  22. y -5
  23. print("报错", obj.z)
  24. AttributeError: type object 'DelClass' has no attribute 'z'

dict的使用:

字典的使用方法

  1. new_dict = dict()
  2. new_dict['key1'] = "test"
  3. print(new_dict)

dir的使用:

该方法将最大限制地收集参数信息, 查看当前,变量,方法, 类型的属性以及功能。

  1. print(dir())
  2. list_one = list()
  3. print(dir(list_one))
  4.  
  5. result
  6. ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
  7.  
  8. ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

divmod的使用:

将除数和余数运算结果结合起来,返回一个包含商和余数的元祖。

  1. ret = divmod(7, 2)
  2. print(ret)
  3. ret_one = divmod(8, 2)
  4. print(ret_one)
  5.  
  6. 参数: 数字
  7.  
  8. result
  9. (3, 1)
  10. (4, 0)

enumerate的使用:

用于将一个可遍历的数据对象(list, tuple,str)组合为一个索引序列,同时列出数据,和数据下标。

  1. test_list = [1, 2, 3, 4, 5]
  2. for data_index, data in enumerate(test_list):
  3. print("下标:{0},数据{1}".format(data_index, data))
  4.  
  5. 参数:
  6. sequence 一个序列,迭代器或其他支持迭代对象
  7. start 下标起始位置
  8.  
  9. result
  10. 下标:0,数据1
  11. 下标:1,数据2
  12. 下标:2,数据3
  13. 下标:3,数据4
  14. 下标:4,数据5

eval的使用:

用来执行一个字符串表达式,并且返回表达式的值

  1. x = 7
  2. ret = eval('x + 3')
  3. print(ret)
  4.  
  5. 参数:
  6. expression 表达式
  7.  
  8. globals 变量作用域,全局命名空间
  9.  
  10. locals 变量作用域,局部命名空间
  11.  
  12. result
  13. 10

exec的使用:

执行存储在字符串或文件中的python语句,相比eval,exec可以执行更复杂的python代码

  1. import time
  2. ret = exec("""for i in range(0,5):
  3. time.sleep(1)
  4. print(i) """)
  5.  
  6. # 注意代码块中的缩进
  7.  
  8. result:
  9.  
  10. 0
  11. 1
  12. 2
  13. 3
  14. 4

filter的使用:

用于过滤序列,过滤掉不符合条件的元素,返回符合条件元素组成的新list

  1. def is_odd(n):
  2. return n % 2 == 1
  3.  
  4. newlist = filter(is_odd, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
  5. print(newlist)
  6.  
  7. 参数:
  8. function 判断函数
  9.  
  10. iterable 可迭代对象
  11.  
  12. result
  13. [1, 3, 5, 7, 9]

float的使用:

将整形转换成小数形

  1. a_int = 10
  2. b_float = float(a_int)
  3. print(a_int)
  4. print(b_float)
  5.  
  6. result
  7. 10
  8. 10.0

format的使用:

字符串序列化,可以序列多种类型

  1. str_format = "Helle World"
  2.  
  3. list_format = ['list hello world']
  4.  
  5. dict_format = {"key_one":"value_one"}
  6.  
  7. ret_format_one = "{0}".format(str_format)
  8. ret_format_two = "{0}".format(list_format)
  9. ret_format_three = "{0}".format(dict_format)
  10. print(ret_format_one)
  11. print(ret_format_two)
  12. print(ret_format_three)
  13.  
  14. result
  15. Helle World
  16. ['list hello world']
  17. {'key_one': 'value_one'}

frozenset的使用:

返回一个冻结集合,集合冻结之后不允许添加,删除任何元素

  1. a = frozenset(range(10)) # 生成一个新的不可变集合
  2. print(a)
  3.  
  4. b = frozenset('wyc') # 创建不可变集合
  5. print(b)
  6.  
  7. result
  8. frozenset({0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
  9. frozenset({'w', 'y', 'c'})

getattr的使用:

用于返回一个对象的属性值

  1. class Foo(object):
  2. bar = 1
  3.  
  4. obj = Foo()
  5. print(getattr(obj, 'bar')) # 获取属性bar的默认值
  6.  
  7. print(getattr(obj, 'bar2')) # 不存在,没设置默认值,则报错
  8.  
  9. print(getattr(obj, 'bar2', 3)) # 属性2不存在,则设置默认值即可
  10.  
  11. result
  12. 1
  13.  
  14. print(getattr(obj, 'bar2'))
  15. AttributeError: 'Foo' object has no attribute 'bar2'
  16.  
  17. 3

globals的使用:

会以字典类型返回当前位置的全部全局变量

  1. print(globals())
  2.  
  3. result
  4. {'__cached__': None, '__name__': '__main__', '__builtins__': <module 'builtins' (built-in)>, '__doc__': None, '__package__': None, '__file__': 'C:/Users/Administrator/PycharmProjects/untitled/day1.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x0000011E78626B70>, '__spec__': None} 

hasattr的使用:

用于判断对象是否包含对应的属性

  1. class Foo:
  2. x = 10
  3. y = 20
  4. z = 0
  5.  
  6. obj = Foo()
  7. print(hasattr(obj, 'x'))
  8. print(hasattr(obj, 'k'))
  9.  
  10. result
  11. True
  12. False

hash的使用:

用于获取一个对象(字符串或者数值等)的哈希值

  1. str_test = "wyc"
  2. int_test = 5
  3.  
  4. print(hash(str_test))
  5. print(hash(int_test))
  6.  
  7. result
  8. 1305239878169122869
  9. 5

help的使用:

帮助查看类型有什么方法

  1. str_test = "wyc"
  2. print(help(str))
  3.  
  4. result
  5. 结果有点小长,就不粘贴再此了 

id的使用:

查看当前类型的存储在计算机内存中的id地址

  1. str_test = "wyc"
  2. print(id(str_test))
  3.  
  4. result
  5. 2376957216616 

input的使用:

接受标准数据,返回一个string类型

  1. user_input = input("请输入:")
  2. print(user_input)
  3.  
  4. result
  5. 请输入:wyc
  6. wyc

isinstance的使用:

判断一个对象是否是一个已知的类型,类似type()

  1. a = 1
  2. print(isinstance(a, int))
  3. print(isinstance(a, str))
  4.  
  5. result:
  6. True
  7. False

issubclass的使用:

用于判断参数class是否是类型参数, classinfo的子类

  1. class A:
  2. pass
  3. class B(A):
  4. pass
  5.  
  6. print(issubclass(B, A)) # 判断B是否是A的子类
  7.  
  8. result
  9. True

iter的使用:

用来生成迭代器

  1. lst = [1, 2, 3]
  2. for i in iter(lst):
  3. print(i)
  4.  
  5. result
  6. 1
  7. 2
  8. 3

len的使用:

查看当前类型里边有多少个元素

  1. str_one = "hello world"
  2. lst = [1, 2, 3]
  3. print(len(str_one)) # 空格也会算一个元素
  4. print(len(lst))
  5.  
  6. result
  7. 11
  8. 3

list的使用:

列表

  1. list = [1, 2, 3, 4, 5]
  2.  
  3. 方法:
  4. 索引: index
  5. 切片: [1:3]
  6. 追加: append
  7. 删除: pop
  8. 长度: len
  9. 扩展: extend
  10. 插入: insert
  11. 移除:remove
  12. 反转: reverse
  13. 排序:sort

locals的使用:

以字典类型返回当前位置的全部,局部变量

  1. def func(arg):
  2. z = 1
  3. return locals()
  4.  
  5. ret = func(4)
  6. print(ret)
  7.  
  8. result
  9. {'arg': 4, 'z': 1}

map的使用:

根据提供的函数对指定序列做映射

  1. def func(list_num):
  2. return list_num * 2
  3.  
  4. print(map(func, [1, 2, 3, 4, 5]))
  5.  
  6. result:
  7. [2, 4, 6, 8, 10]

max的使用:

返回最大数值

  1. ret = max(1, 10)
  2. print(ret)
  3.  
  4. result
  5. 10

memoryview的使用:

返回给定参数的内存查看对象

  1. v = memoryview(bytearray("abc", 'utf-8'))
  2. print(v[0])
  3.  
  4. restlt
  5. 97

min的使用:

取出最小数值

  1. print(min(1, 10))
  2.  
  3. result
  4. 1

next的使用:

返回迭代器的下一个项目

  1. it = iter([1, 2, 3, 4, 5])
  2. while True:
  3. try:
  4. x = next(it)
  5. print(x)
  6. except StopIteration:
  7. # 遇到StopIteration就退出循环
  8. break
  9.  
  10. result
  11. 1
  12. 2
  13. 3
  14. 4
  15. 5

open的使用:

打开一个文件,创建一个file对象,相关的方法才可以调用它的读写

  1. f = open('test.txt')
  2. f.read()
  3. f.close() # 文件读写完成之后,一定要关闭

ord的使用:

函数是 chr() 函数(对于8位的ASCII字符串)或 unichr() 函数(对于Unicode对象)的配对函数,它以一个字符(长度为1的字符串)作为参数,返回对应的 ASCII 数值,或者 Unicode 数值,如果所给的 Unicode 字符超出了你的 Python 定义范围,则会引发一个 TypeError 的异常。

  1. ret = ord('a')
  2. ret1 = ord('b')
  3. ret2 = ord('c')
  4.  
  5. result:
  6. 97
  7. 98
  8. 99

pow的使用:

返回 xy(x的y次方) 的值

  1. import math # 导入 math 模块
  2.  
  3. print "math.pow(100, 2) : ", math.pow(100, 2)
  4. # 使用内置,查看输出结果区别
  5. print "pow(100, 2) : ", pow(100, 2)
  6.  
  7. print "math.pow(100, -2) : ", math.pow(100, -2)
  8. print "math.pow(2, 4) : ", math.pow(2, 4)
  9. print "math.pow(3, 0) : ", math.pow(3, 0)

print的使用:

输出,打印

  1. print('hello world')
  2.  
  3. result:
  4. hello world

property的使用:

新式类中的返回属性值,python3中是新式类,2中是旧式类

  1. class C(object):
  2. def __init__(self):
  3. self._x = None
  4.  
  5. def getx(self):
  6. return self._x
  7.  
  8. def setx(self, value):
  9. self._x = value
  10.  
  11. def delx(self):
  12. del self._x
  13.  
  14. x = property(getx, setx, delx, "I'm the 'x' property.")

range的使用:

输出范围之内的数值

  1. for i in range(1, 5):
  2. print(i)
  3.  
  4. result:
  5. 1
  6. 2
  7. 3
  8. 4
  9. 5

repr的使用:

函数将对象转化为供解释器读取的形式

  1. s = 'RUNOOB'
  2. repr(s)
  3. "'RUNOOB'"
  4. dict = {'runoob': 'runoob.com', 'google': 'google.com'};
  5. repr(dict)
  6. "{'google': 'google.com', 'runoob': 'runoob.com'}"

reversed的使用:

返回一个反转的迭代器

  1. # 字符串
  2. seqString = 'Runoob'
  3. print(list(reversed(seqString)))
  4.  
  5. # 元组
  6. seqTuple = ('R', 'u', 'n', 'o', 'o', 'b')
  7. print(list(reversed(seqTuple)))
  8.  
  9. # range
  10. seqRange = range(5, 9)
  11. print(list(reversed(seqRange)))
  12.  
  13. # 列表
  14. seqList = [1, 2, 4, 3, 5]
  15. print(list(reversed(seqList)))
  16.  
  17. result
  18. ['b', 'o', 'o', 'n', 'u', 'R']
  19. ['b', 'o', 'o', 'n', 'u', 'R']
  20. [8, 7, 6, 5]
  21. [5, 3, 4, 2, 1]

round的使用:

返回浮点数x的四舍五入值

  1. print "round(80.23456, 2) : ", round(80.23456, 2)
  2. print "round(100.000056, 3) : ", round(100.000056, 3)
  3. print "round(-100.000056, 3) : ", round(-100.000056, 3)
  4.  
  5. result
  6. round(80.23456, 2) : 80.23
  7. round(100.000056, 3) : 100.0
  8. round(-100.000056, 3) : -100.0

set的使用:

不可重复元素

  1. a=set((1,2,3,"a","b"))

setattr的使用:

设置属性值,该属性必须存在

  1. class A(object):
  2. bar = 1
  3.  
  4. a = A()
  5. print(getattr(a, 'bar')) # 获取属性 bar 值
  6. 1
  7. setattr(a, 'bar', 5) # 设置属性 bar 值
  8. print(a.bar)

slice的使用:

实现切片对象,主要用在切片操作函数里的参数传递

  1. myslice = slice(5) # 设置截取5个元素的切片
  2. print(myslice)
  3. print(slice(None, 5, None))
  4. arr = range(10)
  5. print(arr)
  6. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  7. print(arr[myslice]) # 截取 5 个元素
  8. [0, 1, 2, 3, 4]

sorted的使用:

所有可迭代的对象进行排序操作

  1. a = [5,7,6,3,4,1,2]
  2. b = sorted(a) # 保留原列表
  3. print(a)
  4. [5, 7, 6, 3, 4, 1, 2]
  5. print(b)
  6. [1, 2, 3, 4, 5, 6, 7]
  7.  
  8. L=[('b',2),('a',1),('c',3),('d',4)]
  9. sorted(L, cmp=lambda x,y:cmp(x[1],y[1])) # 利用cmp函数
  10. [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
  11. print(sorted(L, key=lambda x:x[1])) # 利用key
  12. [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
  13.  
  14. students = [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]
  15. print(sorted(students, key=lambda s: s[2]) ) # 按年龄排序
  16. [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
  17.  
  18. print(sorted(students, key=lambda s: s[2], reverse=True) ) # 按降序
  19. [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]

staticmethod的使用:

返回函数的静态方法

  1. class C(object):
  2. @staticmethod
  3. def f():
  4. print('runoob');
  5.  
  6. C.f(); # 静态方法无需实例化
  7. cobj = C()
  8. cobj.f() # 也可以实例化后调用

str的使用:

字符串

  1. str = "wyc"
  2.  
  3. 方法:
  4. cpitalize 首字母变大写
  5.  
  6. count 子序列个数
  7.  
  8. decode 解码
  9.  
  10. encode 编码针对unicode
  11.  
  12. endswith 是否以xxx结束
  13.  
  14. find 寻找子序列位置,如果没有找到,返回-1
  15.  
  16. format 字符串格式化
  17.  
  18. index 子序列位置,如果没有找到,报错
  19.  
  20. isalnum 是否是字母数字
  21.  
  22. isalpha 是否是字母
  23.  
  24. isdigit 是否是数字
  25.  
  26. islower 是否小写
  27.  
  28. join 拼接
  29.  
  30. lower 变小写
  31.  
  32. lstrip 移除左侧空白
  33.  
  34. replace 替换

sum的使用:

求数值整合

  1. print(sum(1+1))
  2.  
  3. result:
  4. 2

super的使用:

用于调用父类(超类)的一个方法

  1. Python3.x Python2.x 的一个区别是: Python 3 可以使用直接使用 super().xxx 代替 super(Class, self).xxx
  2.  
  3. python3
  4. class A:
  5. pass
  6. class B(A):
  7. def add(self, x):
  8. super().add(x)
  9.  
  10. python2
  11. class A(object): # Python2.x 记得继承 object
  12. pass
  13. class B(A):
  14. def add(self, x):
  15. super(B, self).add(x)

tuple的使用:

元祖,元祖是不可修改的

  1. tuple = (1, 2, 3)

type的使用:

查看当前类型是什么类型

  1. lst = list()
  2. print(type(lst))
  3.  
  4. result:
  5. <class 'list'>

vars的使用:

返回对象object的属性和属性值的字典对象

  1. print(vars())
  2. {'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None, '__package__': None}
  3. class Runoob:
  4. a = 1
  5.  
  6. print(vars(Runoob))
  7. {'a': 1, '__module__': '__main__', '__doc__': None}
  8. runoob = Runoob()
  9. print(vars(runoob))
  10. {}

zip的使用:

函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。

如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作符,可以将元组解压为列表。

  1. a = [1,2,3]
  2. b = [4,5,6]
  3. c = [4,5,6,7,8]
  4. zipped = zip(a,b) # 打包为元组的列表
  5. [(1, 4), (2, 5), (3, 6)]
  6. zip(a,c) # 元素个数与最短的列表一致
  7. [(1, 4), (2, 5), (3, 6)]
  8. zip(*zipped) # 与 zip 相反,*zipped 可理解为解压,返回二维矩阵式
  9. [(1, 2, 3), (4, 5, 6)]

__import__的使用:

函数用于动态加载类和函数

  1. import time os

扩展进制转换:

  1. 二进制转换十进制
  2.  
  3. int('0b11', base=2)
  4.  
  5. result: 3
  6.  
  7. 八进制转换十进制
  8.  
  9. int('', base=8)
  10.  
  11. result: 9
  12.  
  13. 十六进制转换十进制
  14.  
  15. int('0xe', base=16)
  16.  
  17. result: 14

以上有不足之处,请大神,留下宝贵的建议,本人看到第一时间添加。

最全Python内置函数的更多相关文章

  1. 【转】python 内置函数总结(大部分)

    [转]python 内置函数总结(大部分) python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为 ...

  2. python 内置函数总结(大部分)

    python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为我们提供了68个内置函数.它们就是pytho ...

  3. python内置函数详细介绍

    知识内容: 1.python内置函数简介 2.python内置函数详细介绍 一.python内置函数简介 python中有很多内置函数,实现了一些基本功能,内置函数的官方介绍文档:    https: ...

  4. python内置函数简单归纳

    做python小项目的时候发现熟练运用python内置函数,可以节省很多的时间,在这里整理一下,便于以后学习或者工作的时候查看.函数的参数可以在pycharm中ctrl+p查看. 1.abs(x):返 ...

  5. python内置函数

    python内置函数 官方文档:点击 在这里我只列举一些常见的内置函数用法 1.abs()[求数字的绝对值] >>> abs(-13) 13 2.all() 判断所有集合元素都为真的 ...

  6. python 内置函数和函数装饰器

    python内置函数 1.数学相关 abs(x) 取x绝对值 divmode(x,y) 取x除以y的商和余数,常用做分页,返回商和余数组成一个元组 pow(x,y[,z]) 取x的y次方 ,等同于x ...

  7. Python基础篇【第2篇】: Python内置函数(一)

    Python内置函数 lambda lambda表达式相当于函数体为单个return语句的普通函数的匿名函数.请注意,lambda语法并没有使用return关键字.开发者可以在任何可以使用函数引用的位 ...

  8. [python基础知识]python内置函数map/reduce/filter

    python内置函数map/reduce/filter 这三个函数用的顺手了,很cool. filter()函数:filter函数相当于过滤,调用一个bool_func(只返回bool类型数据的方法) ...

  9. Python内置函数进制转换的用法

    使用Python内置函数:bin().oct().int().hex()可实现进制转换. 先看Python官方文档中对这几个内置函数的描述: bin(x)Convert an integer numb ...

随机推荐

  1. sql 将一张表中的数据插入到另一张表

    将表T_wz_wz中的部分数据插入到表t_wz_kc: insert into t_wz_kc(wzid,jldwid,kcsl,yfpkcsl,cshwcbz) select wzid,jldwid ...

  2. 在CentOS7下从0开始搭建docker并发布tomcat项目

    一切从0开始,我也是个小白: 1.检查你的系统是不是高于3.8的内核,如果没有请升级CentOS7或者Ubuntu 14 #uname -a 2.CentOS7下安装docker #yum -y in ...

  3. tcp/ip三次握手及四次挥手

    三次握手Three-way Handshake 一个虚拟连接的建立是通过三次握手来实现的 1. (B) –> [SYN] –> (A) 假如服务器A和客户机B通讯. 当A要和B通信时,B首 ...

  4. 记一次踩坑:使用ksoap-android时造成的okhttp依赖冲突问题

    项目中需要调用webservice接口,android SDK中并没有直接访问webservice接口的方法,于是我引入了ksoap-android的jar包,来实现访问webservice接口.刚开 ...

  5. java.util.ResourceBundle 读取国际化资源或配置文件

    1.定义三个资源文件,放到src的根目录下面 命名规范是: 自定义名_语言代码_国别代码.properties 默认 : 自定义名.properties   2.资源文件都必须是ISO-8859-1编 ...

  6. windows 系统无法启动windows event log 服务

    windows 系统无法启动windows event log 服务 关键词:无法启动系统事件日志 尝试解决步骤 [1]权限:把如图中logsfile文件等都给local service [2]把C: ...

  7. python之sqlalchemy使用

    一.介绍 SQLAlchemy是一个基于Python实现的ORM框架.该框架建立在 DB API之上,使用关系对象映射进行数据库操作,简言之便是:将类和对象转换成SQL,然后使用数据API执行SQL并 ...

  8. 认识与设计Serverless(二)

    一.设计Serverless的功能模块 第一节讲了Serverless一些概念与特性,废话居多,概念的东西了解过后要有设计与构思,才能学到精髓,一个Serverless平台的形成,涉及到很多模块的架构 ...

  9. MyBtis—原理及初始化

    Mybatis的功能架构分为三层: 1)       API接口层:提供给外部使用的接口API,开发人员通过这些本地API来操纵数据库.接口层 一接收到调用请求就会调用数据处理层来完成具体的数据处理. ...

  10. Codeforces Round #275 (Div. 2) 题解

    A 题: 说的是在(LR) 之间找出ab互质 bc 互质 ac 不互质的 3个数 数据量小直接暴力 #include <iostream> #include <cstdio> ...