将坐标转换为第几张图

to_num.py

def axis_to_num(axis):  # 接收坐标字符串 形如 '256,145'
    temp = [int(x.strip()) for x in axis.split(',')]
    axis = [(temp[i], temp[i + 1]) for i in range(0, len(temp), 2)]
    for num in axis:
        for i in range(4):
            if 4 + 72 * i < num[0] < 72 * (i + 1):
                for j in range(2):
                    if 40 + 72 * j < num[1] < 108 + 72 * j:
                        return (i + 1) * (j + 1)

你可能感兴趣的:(将坐标转换为第几张图)