def test(a:int,b:str)->str:print(a)return btest(1,"abc")
As shown in the sample code above, type annotations add type descriptions by colons after parameters:
a:intmeansspecify the input parameter a as int type
b:strmeansspecify the input parameter b as str type
->strIndicates that the return value of the specified test function is srt typep>
Special note: Type annotations are only a type description for parameters, they do not enforce static type checking.
In other words, although the parameter a defines the int type, if you pass a string, the type annotation will not automatically report an error, and you may find the parameter a only in the process of subsequent code running.Type passed error.
As the project gets bigger and bigger, there will be more and more code. In this case, if there is no type annotation, it is easy for us to forget what the input parameter type of a method is