python turtle方向_Python turtle.left()用法及代码示例

turtle 模块以面向对象和面向过程的方式提供 turtle 图形基元。由于它使用Tkinter作为基础图形,因此需要安装有Tk支持的Python版本。

turtle .left()

turtle.left()方法用于通过其参数值来更改 turtle 的方向。它使 turtle 的头部朝一个方向移动。

turtle.left(angle)

它接受的参数是angle {一个数字(整数或浮点数)}。因此,它以角度单位向左转 turtle 。 (单位默认为度,但可以通过degrees()和radians()功能进行设置。)角度方向取决于模式。

下面是上述方法的实现和一些示例:

范例1:

Python3

# importing package

import turtle

# move the turtle forward by

# 100 unit distance in the

# direction of head of turtle

turtle.forward(100)

# change the direction of turtle

# by 90 degrees to the left.

turtle.left(90)

# move the turtle forward by

# 100 unit distance in the

# direction of head of turtle

turtle.forward(100)

输出:

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值