【问题标题】:Drawing basic bipartite graph with Turtle: TypeError?用 Turtle 绘制基本二部图:TypeError?
【发布时间】:2015-11-06 03:20:18
【问题描述】:

我收到此错误: 类型错误:setx() 缺少 1 个必需的位置参数:'x'

当我尝试在 Python 中运行此代码时:

import turtle
myScreen = turtle.Screen()
myScreen.setup(0.5,0.75,0,0)
t = turtle.Turtle
coord_list_1 = [[-200,200],[-200,90],[-50,-20]]
coord_list_2 = [[50,200],[50,170],[300,90],[50,30],[50,0],[50,-13],[50,-73]]
def drawBipartiteGraph(inputList,inputList2):
    for m in range(0,len(inputList)):
        for n in range(0,len(inputList2)):
            t.setx(inputList[m][0])
            t.sety(inputList[m][1])
            t.pd()
            t.goto(inputList2[n][0],inputList2[n][1])
            t.goto(inputList[m][0],inputList[m][1])
            t.pu()
drawBipartiteGraph(coord_list_1,coord_list_2)

这可能是一个愚蠢的问题,但我似乎无法弄清楚为什么它会输出该错误。我写代码的方式有问题吗?

谢谢!

【问题讨论】:

    标签: python graph turtle-graphics


    【解决方案1】:

    变化:

    t = turtle.Turtle
    

    到:

    t = turtle.Turtle()
    

    【讨论】:

      猜你喜欢
      • 2019-08-08
      • 1970-01-01
      • 2021-05-17
      • 1970-01-01
      • 2021-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多