在这种情况下,“反斜杠”在做什么?

问题描述 投票:0回答:1

下面的代码是constructed,它是查找列表中两个元素最接近的对的有效方法:

idx = np.searchsorted(xx, yy, side="left").clip(max=xx.size-1)
mask = (idx > 0) &  \
       ( (idx == len(xx)) | (np.fabs(yy - xx[idx-1]) < np.fabs(yy - xx[idx])) )
out = xx[idx-mask]

我有一个简单的问题:这段代码中的反斜杠是什么?我尝试使用谷歌搜索并尝试使用不同的代码来解决自己的问题,例如:

enter image description here

[这里,我看到反斜杠似乎不是对numpy数组起作用的运算符。

python numpy backslash
1个回答
1
投票

\line continuation character。这之后的非空白字符将触发SyntaxError,因为您已经发现了困难的方法。

© www.soinside.com 2019 - 2024. All rights reserved.