Python3 has built-in functions


May 10, 2021 04:00 Python3


Table of contents


Python3 has built-in functions

This section describes the built-in functions in Python3.

Built-in functions
abs() dict() help() min() setattr()
all() dir() hex() next() slice()
any() divmod() id() object() sorted()
ascii() enumerate() input() oct() staticmethod()
bin() eval() int() open() str()
bool() 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()
delattr() hash() memoryview() set()

Python debugging method

1、print

print('here')
# 可以发现某段逻辑是否执行
# 打印出变量的内容

2、assert

assert false, 'blabla'
# 如果条件不成立,则打印出 'blabla' 并抛出AssertionError异常

3、debugger

Debugging can be done with tools such as pdb and IDE.

The specific method of debugging is not expanded here.

There are two built-in methods in Python that are also helpful here:

  • locals: After executing locals(), returns a dictionary that contains local variables under the current scope.
  • Globals: After performing globals(), returns a dictionary that contains global variables under the current scope.