Type hints may be built-in classes (including those defined in standard library or third-party extension modules), abstract base classes, types available in the types module, and user-defined classes (including those defined in the standard library or third-party modules).
我可能错了,因为我在Python3.5中还没有深入研究过,但是看看documentation你应该可以用
typing.Optional
来完成。一个简单的例子。在希望有帮助。在
你只需要使用类本身。在
来自the PEP(重点是我的):
相关问题 更多 >
编程相关推荐