- set和frozenset的区别。
set是mutable的,所以set不能被hash,无法当作dict的key。
frozenset是immutable的,创建后不能修改,可以被hash,可以当作dict的key。 - BaseException是所有异常的基类,但是不建议用户直接继承BaseException定义自己的异常。继承Exception或者它的子类,来创建自定义异常。
- 异常家谱树
BaseException
±- SystemExit
±- KeyboardInterrupt
±- GeneratorExit
±- Exception
±- StopIteration
±- StopAsyncIteration
±- ArithmeticError
| ±- FloatingPointError
| ±- OverflowError
| ±- ZeroDivisionError
±- AssertionError
±- AttributeError
±- BufferError
±- EOFError
±- ImportError
| ±- ModuleNotFoundError
±- LookupError
| ±- IndexError
| ±- KeyError
±- MemoryError
±- NameError
| ±- UnboundLocalError
±- OSError
| ±- BlockingIOError
| ±- ChildProcessError
| ±- ConnectionError
| | ±- BrokenPipeError
| | ±- ConnectionAbortedError
| | ±- ConnectionRefusedError
| | ±- ConnectionResetError
| ±- FileExistsError
| ±- FileNotFoundError
| ±- InterruptedError
| ±- IsADirectoryError
| ±- NotADirectoryError
| ±- PermissionError
| ±- ProcessLookupError
| ±- TimeoutError
±- ReferenceError
±- RuntimeError
| ±- NotImplementedError
| ±- RecursionError
±- SyntaxError
| ±- IndentationError
| ±- TabError
±- SystemError
±- TypeError
±- ValueError
| ±- UnicodeError
| ±- UnicodeDecodeError
| ±- UnicodeEncodeError
| ±- UnicodeTranslateError
±- Warning
±- DeprecationWarning
±- PendingDeprecationWarning
±- RuntimeWarning
±- SyntaxWarning
±- UserWarning
±- FutureWarning
±- ImportWarning
±- UnicodeWarning
±- BytesWarning
±- ResourceWarning
Python知识点梳理
最新推荐文章于 2022-10-28 11:29:10 发布