Python void return type annotation

前端 未结 2 799
悲哀的现实
悲哀的现实 2021-01-31 06:33

In python 3.x, it is common to use return type annotation of a function, such as:

def foo() -> str:
    return \"bar\"

What is the correct a

2条回答
  •  青春惊慌失措
    2021-01-31 07:10

    This is straight from PEP 484 -- Type Hints documentation:

    When used in a type hint, the expression None is considered equivalent to type(None).

    And, as you can see most of the examples use None as return type.

提交回复
热议问题