如果要照原本語意的話可以這樣寫:
for i, j in zip(range(start, start + cnt), range(8 * (cnt - 1), -1, -8)):
tmp = arr[i] & 0xFF
result = result | tmp << j
但我會比較傾向寫成這樣,感覺可讀性會好些:
i = start
j = 8 * (cnt - 1)
for _ in range(cnt):
tmp = arr[i] & 0xFF
result = result | tmp << j
i += 1
j -= 8