1. reversed() a = [1, 2, 3, 4] for i in reversed(a): print(i) 2. range(len(a)-1, -1, -1) a = [1, 2, 3, 4] for i in range(len(a)-1, -1, -1): print(a[i]) 3. range(len(a)) + ~操作符 ~按位取反运算符:对数据的每个二进制位取反,即把1变为0,把0变为1 .~x 类似于 -x-1 a = [1, 2, 3, 4] for i in
1. reversed() a = [1, 2, 3, 4] for i in reversed(a): print(i) 2. range(len(a)-1, -1, -1) a = [1, 2, 3, 4] for i in range(len(a)-1, -1, -1): print(a[i]) 3. range(len(a)) + ~操作符 ~按位取反运算符:对数据的每个二进制位取反,即把1变为0,把0变为1 .~x 类似于 -x-1 a = [1, 2, 3, 4] for i in
链接 遍历NSArray 正向遍历 for (id object in array) 反向遍历 for (id object in [array reverseObjectEnumerator]) 如果在遍历中修改 先计算出array的count,然后使用for循环.在for循环中记录需要修改的index,然后修改. NSUInteger count = [array count]; for (NSUInteger i = 0; i < count; i++) { id object = arr