2016-11-04 32 views
0

好的,去了Python.com,并加载了这个页面 https://docs.python.org/3.6/library/turtle.html Turtle Coding的基础知识。来自Python网站的龟代码不工作

Right there they have a code that makes a red and yellow star

from turtle import * 
color('red', 'yellow') 
begin_fill() 
while True: 
    forward(200) 
    left(170) 
    if abs(pos()) < 1: 
     break 
end_fill() 
done() 

嗯,我想这个代码我自己,这是行不通的。我收到一条错误消息,说ExternalError:TypeError:无法读取第2行未定义的属性“应用”

我错过了什么吗?我相信我正在运行Python 3.6。我得说,它不会激发出很大的信心从Python网站似乎什么时候不工作...

UPDATE

好吧,我跟老师在我的Python类和显然我们使用的“Python”程序与实际的Python稍有不同。我不确定,但我认为他们说这是通过Javescript模拟的。所以,我不得不添加更基本的东西,像“龟进口”,名龟等

import turtle 
wn=turtle.Screen 
mark=turtle.Turtle() 
mark.color('red', 'yellow') 
mark.begin_fill() 
while True: 
    mark.forward(100) 
    mark.left(170) 
    if abs(mark.xpos()) < 1: 
     break 
end_fill() 
done() 

当我运行这个程序,它绘制一条线,变成乌龟说:“AttributeError错误:“龟'object has no attribute'xpos'on line 9“

+1

您提供运行原样Python3和Python2下我的系统上的代码。您引用的错误消息似乎最经常与JavaScript相关联,而不是Python - 您能否提供代码执行的抄本,包括产生的错误消息? – cdlane

+0

这有帮助吗? http://i.imgur.com/pK3qc3d.jpg – Mallan627

+0

我看着你的页面图像,看着ActiveCode。它支持Python和JavaScript(以及其他语言),并使用像'language:python'这样的标签扩展到'