函数式接口
一个接口,只有一个方法
@Functionallnterface
可选,非必选
1 |
|
常用的函数式接口:
In Java, Collection interface (java.util.Collection
) and Map interface (java.util.Map
) are the two main “root” interfaces of Java collection classes.
文档:https://docs.python.org/3/tutorial/controlflow.html#function-annotations
1 | def f(ham: str, eggs: str = 'eggs') -> str: |
Type Hints 是 Python3.5 添加的特性,旧版没有
同时还有变量注解:
1 | age: int = 20 |
https://www.w3schools.com/python/python_datatypes.asp
Text: str
Numeric: int
, float
, complex
Sequence: list
, tuple
, range
Mapping: dict
Set: set
, frozenset
Boolean: bool
Binary: bytes
, bytearray
, memoryview
None: NoneType