【问题标题】:in dlib python API document, what does "->None" mean?在 dlib python API 文档中,“->None”是什么意思?
【发布时间】:2021-01-13 20:38:38
【问题描述】:

在 dlib Python API 文档中,我看到了这些内容(忽略颜色,我不知道为什么..),
(来自http://dlib.net/python/index.html#dlib.rectangles

class dlib.chip_details
WHAT THIS OBJECT REPRESENTS This object describes where an image chip is to be extracted from within another image. In particular, it specifies that the image chip is contained within the rectangle self.rect and that prior to extraction the image should be rotated counter-clockwise by self.angle radians. Finally, the extracted chip should have self.rows rows and self.cols columns in it regardless of the shape of self.rect. This means that the extracted chip will be stretched to fit via bilinear interpolation when necessary.

__init__(*args, **kwargs)
Overloaded function.

__init__(self: dlib.chip_details, rect: dlib.drectangle) -> None
__init__(self: dlib.chip_details, rect: dlib.rectangle) -> None
ensures
self.rect == rect_
self.angle == 0
self.rows == rect.height()
self.cols == rect.width()
__init__(self: dlib.chip_details, rect: dlib.drectangle, size: int) -> None
__init__(self: dlib.chip_details, rect: dlib.rectangle, size: int) -> None
ensures
...

“->无”是什么意思?

【问题讨论】:

  • 这是一个类型注解。在这种情况下,这意味着__init__ 方法返回None

标签: python dlib


【解决方案1】:

-> None 是 python typing 的一部分。在这种情况下,这意味着该函数不返回任何内容。

注意 Python 运行时不强制执行函数和变量类型注释。它们可供第三方工具使用,例如类型检查器、IDE、linter 等。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-11
  • 1970-01-01
  • 2020-08-25
  • 2018-04-24
相关资源
最近更新 更多