索引错误:字符串索引超出范围 python 旋转甜甜圈调试

问题描述

所以这是旋转的甜甜圈 ASCII,我是 python 的新手,并挑战自己写出这段代码并尝试围绕它,但我开始尝试调试并出现错误,我不太确定功能呢。为什么要这样做?

for j in range(0,628,theta_spacing):
    for i in range(0,phi_spacing):
        c = math.sin(i)
        d = math.cos(j)
        e = math.sin(A)
        f = math.sin(j)
        g = math.cos(A)
        h = d + 2
        D = 1 / (c * h * e + f * g + 5)
        l = math.cos(i)
        m = math.cos(B)
        n = math.sin(B)
        t = c * h * g - f * e
        x = int(x_offset + 40 * D * (l * h * m - t * n))
        y = int(y_offset + 20 * D * (l * h * n + t * m))
        o = int(x + columns * y)
        N = int(8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n))
        if rows > y and y > 0 and x > 0 and columns > x and D > z[o]:
            z[o] = D
            b[o] = chars[N if N > 0 else 0]  #this line is the cause of the error

IndexError: 字符串索引超出范围

这只是代码片段。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)