美文网首页
Python学习笔记之【内建函数】2019-08-08

Python学习笔记之【内建函数】2019-08-08

作者: 平知 | 来源:发表于2019-08-08 08:17 被阅读0次
函数名 函数名
abs() delattr() hash() memoryview() set()
all() dict() help() min() setattr()
any() dir() hex() next() slice()
ascii() divmod() id() object() sorted()
bin() enumerate() input() oct() staticmethod()
bool() eval() int() open() str()
breakpoint() exec() isinstance() ord() sum()
bytearray() filter() issubclass() pow() super()
bytes() float() iter() print() tuple()
callable() format() len() property() type()
chr() frozenset() list() range() vars()
classmethod() getattr() locals() repr() zip()
compile() globals() map() reversed() __import__()
complex() hasattr() max() round()

函数(测试环境:ipython)

  • abs(x). Return the absolute value of a number.
  • all(iterable). Return True if any element of the iterable is true. If the iterable is empty, return False.
hasattr(myObj, '__iter__')
#或者
In [19]: a=[]
    ...: a.__iter__
    ...: a.__iter__()
    ...: 
Out[19]: <list_iterator at 0x7fac201854e0>

  • any(iterable). Return True if any element of the iterable is true. If the iterable is empty, return False.

  • ascii(object). As repr(), return a string containing a printable representation of an object

In [8]: ascii([1,2,3,4])
Out[8]: '[1, 2, 3, 4]'

In [9]: a=ascii([1,2,3,4])

In [10]: type(a)
Out[10]: str
  • bin(x). Convert an integer number to a binary string prefixed with “0b”.
In [18]: bin(123)
Out[18]: '0b1111011'

相关文章

网友评论

      本文标题:Python学习笔记之【内建函数】2019-08-08

      本文链接:https://www.haomeiwen.com/subject/duttjctx.html