'范围'对象不支持将项目分配给数组的int分配

时间:2019-04-13 15:26:35

标签: python python-3.x

我尝试运行一个图像加密程序,该程序在消除了我被这段代码所卡住的大部分错误后,原来的程序在2.7中

项目文件的原始链接为https://github.com/AtheMathmo/ImageEncryptor/blob/master/ImageEncryptor/utils.py

尝试过该列表(p)

def main():
start = time.time()
two_kdp(25000, 12412513, 345987439589897)
end = time.time()
print (end - start)

def two_kdp(size,k1,k2):

# Initialization
y = 1
z = 1
p = k1 * k2

C = list(range(len(size)))

# Generate set
for i in range(size):
    w = y + (k2 + i)
    x = z + (k1 + i)

    y += w
    z += x + y

    p = (p + y + z) % size

    C[i] = int(p) (stuck at this point)

1 个答案:

答案 0 :(得分:0)

您可以执行此操作。在for循环中附加每个元素。

C = []
C.append(1)
C
[1]

或者在这里看看:

range to list

相关问题