元组对象不可调用[保留]

问题描述 投票:0回答:2

我一直在研究创建可旋转的多维数据集的代码,我编写了一个有效的版本,但是我试图压缩代码以使其更简单...我试图创建顶点(我认为这是指多维数据集上的交集),然后将调用这些顶点以创建代码

简而言之:为什么会创建元组错误?


######
import turtle
import math

cube = turtle.Turtle()
cube.speed(0)
cube.ht()

def cube(size):
    point_select = 0
    vertex = [(0,0),(0,size),(size,0)(size,size),(size/2,size/2),(size,size/2 + size),(size/2,size/2 + size), (size/2 + size,size/2 + size)]
    print(vertex[point_select])
    for draw_cube in range(8):
        cube.goto(int(vertex[point_select]))
        point_select = point_select + 1

cube(100)

我忘了在原始帖子中提及此,这是错误:

vertex = [(0,0),(0,size),(size,0)(size,size),(size/2,size/2),(size,size/2 + size),(size/2,size/2 + size), (size/2 + size,size/2 + size)]
TypeError: 'tuple' object is not callable
python tuples cube
2个回答
0
投票

通过在vertex上固定逗号并正确定义方法名称,可以使脚本起作用。


-1
投票

您在这里缺少逗号:

© www.soinside.com 2019 - 2024. All rights reserved.