学习笔记,参考文档《Python CookBook》
# -*- coding: utf-8 -*-
# @CreateTime : 2022/5/10 8:49
# @ModifyTime : 2022/5/10 8:49
# @Author : xuming
# @File : 7.3将元数据信息附加到函数参数上.py
# @Software: PyCharm
# @Description:
"""
给函数参数附加额外的信息,其目的是帮忙函数使用者更加方便的了解
函数的使用
"""
def add(x: int, y: int) -> int:
return x + y
print(add(10, 12))
# 函数的注释只会保存在__annotations__属性中
print(add.__annotations__)