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__) # 查看自己定义的全部提示