[英]What is “backslash” doing in this context?
The following code was constructed to be an efficent method of finding the the closest pairs for two elements in a list:下面的代码被构造为一种为列表中的两个元素找到最接近的对的有效方法:
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]
I have a simple question: What is the backslash doing in this code?我有一个简单的问题:这段代码中的反斜杠是做什么的? I've tried googling and trying different codes to figure it out myself without success, for example:我试过谷歌搜索并尝试不同的代码来自己弄清楚但没有成功,例如:
Here I see that it doesn't seem like the backslash is an operator that acts on numpy arrays.在这里,我看到反斜杠似乎不是作用于 numpy arrays 的运算符。
\
is the line continuation character . \
是行继续符。 Non-whitespace characters after this, will trigger a SyntaxError
, as you have discovered the hard way.此后的非空白字符将触发SyntaxError
,因为您已经发现了困难的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.