typing — 支持类型提示

Added in version 3.5.

源代码: Lib/typing.py

注意

The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers , IDEs, linters, etc.


This module provides runtime support for type hints.

Consider the function below:

def surface_area_of_cube(edge_length: float) -> str:
    return f"The surface area of the cube is {6 * edge_length ** 2}."