Python——补充函数知识点(类型提示:Type hinting)

类型提示:Type hinting(最低python版本为3.5)

def register(name:str,age:int,hobbies:tuple):
    print(name)
    print(age)
    print(hobbies)
    return 200
register('egon',18,['play','eat','sleep'])

# 类型提示
def register(name: str, age: int, hobbies: tuple)-> int:
    print(name)
    print(age)
    print(hobbies)
    return 200
res = register('egon',18,('play','eat','sleep'))

print(register.__annotations__) # 查看自己定义的全部提示
posted @ 2020-03-27 20:07  群青-Xi  阅读(375)  评论(0编辑  收藏  举报