我正在使用这个小代码生成加权模103校验和。 问题是当我运行以下代码时:
@Beta
public class HttpBackOffUnsuccessfulResponseHandler implements HttpUnsuccessfulResponseHandler {
* {@inheritDoc}
*
* <p>
* Handles the request with {@link BackOff}. That means that if back-off is required a call to
* {@link Sleeper#sleep(long)} will be made.
* </p>
*/
public final boolean handleResponse(
HttpRequest request, HttpResponse response, boolean supportsRetry) throws IOException {
if (!supportsRetry) {
return false;
}
// check if back-off is required for this response
if (backOffRequired.isRequired(response)) {
try {
return BackOffUtils.next(sleeper, backOff);
} catch (InterruptedException exception) {
// ignore
}
}
return false;
}
当输入长度为10的数组时,我得到x的以下结果:
def checksum_bar(array):
s = array[0]
s += array[1]
for x in range(2, len(array)):
print x
s += array[x] * x
m = s % 103
但是当我运行以下代码时(第3行评论):
1
2
3
4
5
6
7
8
9
10
它给了我想要的结果,即使我没有改变迭代:
def checksum_bar(array):
s = array[0]
#s += array[1]
for x in range(2, len(array)):
print x
s += array[x] * x
m = s % 103
我在这里遗漏了什么吗?我想知道是否有人可以重现相同的结果,一些解释也会非常好。
答案 0 :(得分:0)
提供的两组代码将给出相同的结果,因为范围函数肯定从2
开始