函数文档的参数中的方括号是什么意思?

What does square bracket mean in args of function docs?

当我遇到这个时,我正在浏览 cv2.resize 的 opencv 文档:

cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) → dst

方括号表示什么?我在文档的很多地方都遇到过它们。方括号的层次结构重要吗? (最内层和最外层)一个例子真的很有帮助。这是文档的 link:https://docs.opencv.org/3.0-beta/modules/imgproc/doc/filtering.html

它是documentation style
以下是几个例子:

image = cv2.imread("my_image.jpg") # src

# resize the image to 200x200px, ignoring aspect ratio
resized = cv2.resize(image, (200, 200))
cv2.imshow("Fixed Resizing", resized)

# fixed resizing and distort aspect ratio 
# to be 300px but compute the new height based on the aspect ratio
image = cv2.imread("my_image.jpg") # src
(h, w, d) = image.shape
print("width={}, height={}, depth={}".format(w, h, d))
r = 300.0 / w
dim = (300, int(h * r))
resized = cv2.resize(image, dim)
cv2.imshow("Aspect Ratio Resize", resized)

方括号表示不需要参数。

您只需要传递 srcdsize 参数。