Python中的turtle.mode()函数

您所在的位置:网站首页 turtle的setheading函数 Python中的turtle.mode()函数

Python中的turtle.mode()函数

2024-07-15 17:45| 来源: 网络整理| 查看: 265

Python中的turtle.mode()函数

turtle模块以面向对象和面向过程的方式提供Turtle图形基元。因为它使用 Tkinter 作为底层图形,它需要安装一个支持 Tk 的 Python 版本。

turtle.mode()

该函数用于设置Turtle模式(’标准’、’标识’或’世界’)并执行复位。

语法: turtle.mode(mode=None)

参数:

mode:“standard”、”logo”或 “world”中的一个字符串。

模式standard与turtle.py兼容。 模式logo与大多数Logo-Turtle-Graphics兼容。 模式world使用用户定义的 “世界坐标”。

下面是上述方法的实现和一些例子。

例子1 :

# importing package import turtle    # check by default value print(turtle.mode())

输出 :

standard

例子2 :

# importing package import turtle    # motion with default mode (standard) # default direction of turtle head  # is north in standard mode turtle.forward(180)    # set mode to 'logo' mode turtle.mode(mode='logo')    # do some motion # default direction of turtle head  # is east in logo mode turtle.forward(120)    # set mode to 'world' mode turtle.mode(mode='world')    # do some motion turtle.forward(100)    # set coordinates of the turtle  # mode (world) by choice of user turtle.setworldcoordinates(-500,-500,500,500)

输出 :

Python中的turtle.mode()函数



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3