函数补充之类型提示

补充函数的知识点:
类型提示 Type hinting(最低 Python 版本为 3.5)

def register(name:"必须传入名字傻叉",age:1111111,hobbbies:"必须传入爱好元组")->"返回的是整型":
# 可以在函数形参的后面跟 :加提示信息
print(name)
print(age)
print(hobbbies)
return 111

# register(1,'aaa',[1,])
# res=register('egon',18,('play','music'))
# res=register('egon',19,(1,2,3))

print(register.__annotations__)
#可以用函数名.__annotations__查看提示信息

猜你喜欢

转载自www.cnblogs.com/h1227/p/12584949.html