Screen和Turtle类的公共方法通过docstrings广泛记录。所以这些可以通过Python帮助工具用作在线帮助:
使用IDLE时,工具提示会显示函数/方法调用中键入的文档字符串的签名和第一行。
调用help()方法或函数会显示文档字符串:
help(Screen.bgcolor)
Help on method bgcolor in module turtle:
bgcolor(self, *args) unbound turtle.Screen method
Set or return backgroundcolor of the TurtleScreen.
Arguments (if given): a color string or three numbers
in the range 0..colormode or a 3-tuple of such numbers.
>>> screen.bgcolor("orange")
>>> screen.bgcolor()
"orange"
>>> screen.bgcolor(0.5,0,0.5)
>>> screen.bgcolor()
"#800080"
help(Turtle.penup)
Help on method penup in module turtle:
penup(self) unbound turtle.Turtle method
Pull the pen up – no drawing when moving.
Aliases: penup | pu | up
No argument
>>> turtle.penup()
从方法派生的函数的文档字符串具有修改的形式:
help(bgcolor)
Help on function bgcolor in module turtle:
bgcolor(*args)
Set or return backgroundcolor of the TurtleScreen.
Arguments (if given): a color string or three numbers
in the range 0..colormode or a 3-tuple of such numbers.
Example::
>>> bgcolor("orange")
>>> bgcolor()
"orange"
>>> bgcolor(0.5,0,0.5)
>>> bgcolor()
"#800080"
help(penup)
Help on function penup in module turtle:
penup()
Pull the pen up – no drawing when moving.
Aliases: penup | pu | up
No argument
Example:
>>> penup()
这些修改过的文档字符串是与导入时从方法派生的函数定义一起自动创建的。