索引器错误:图像索引超出范围

2024-09-21 03:20:13 发布

您现在位置:Python中文网/ 问答频道 /正文

def main():

    im = Image.open('terrain.png')
    ter = im.load()

    terr = []
    for row in range(500):
        trow = []
        for col in range(400):
            if ter[col,row][0:3] not in terrains:

                print((row,col))
                trow.append(5)
            else:
                trow.append(terrains[ter[col,row][0:3]])
        terr.append(trow)
    source = (200, 200)
    destination = (300, 300)

File "/Users/pranushasoma/Downloads/hw1b.py", line 175, in main

if ter[col,row][0:3] not in terrains:

IndexError: image index out of range

对于这个错误我能做些什么?在


Tags: inforifmaindefnotrangecol

热门问题