相关疑难解决方法(0)

如何使用类型提示指定"可空"返回类型

假设我有一个功能:

def get_some_date(some_argument: int=None) -> %datetime_or_None%:
    if some_argument is not None and some_argument == 1:
        return datetime.utcnow()
    else:
        return None
Run Code Online (Sandbox Code Playgroud)

如何为可能的内容指定返回类型None

python type-hinting python-3.x python-3.5

133
推荐指数
2
解决办法
3万
查看次数

标签 统计

python ×1

python-3.5 ×1

python-3.x ×1

type-hinting ×1