typing 模块 - 图1


    1. # typing模块:返回值类型规范,并不会报错
    2. # python:3.6以后才有的这个模块
    3. from typing import List, Tuple, Dict
    4. '''
    5. int、long、float: 整型、长整形、浮点型
    6. bool、str: 布尔型、字符串类型
    7. List、 Tuple、 Dict、 Set:列表、元组、字典、集合
    8. Iterable、Iterator:可迭代类型、迭代器类型
    9. Generator:生成器类型
    10. '''
    11. # def test(a:int,b:int)->Tuple[int,str]:
    12. # def test(a:int,b:int)->Dict:
    13. # def test(a,b):
    14. # # return a+b
    15. #
    16. #
    17. # return ('sss','sss')
    18. #
    19. # res=test(1,3)
    20. # print(res)