欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python?turtle.shape()用法及實(shí)戰(zhàn)案例

 更新時(shí)間:2024年03月19日 11:02:34   作者:宇龍神  
turtle是Python自帶的一個(gè)小型的繪圖庫(kù),它可以幫助我們快速地繪制簡(jiǎn)單的圖形,這篇文章主要給大家介紹了關(guān)于Python?turtle.shape()用法及實(shí)戰(zhàn)案例的相關(guān)資料,需要的朋友可以參考下

前言

turtle 模塊以面向?qū)ο蠛兔嫦蜻^(guò)程的方式提供 turtle 圖形基元。

由于它使用tkinter作為基礎(chǔ)圖形,因此需要安裝有Tk支持的Python版本。

Python3默認(rèn)帶有turtle和tkinter 庫(kù),可以直接使用不需要另外安裝

turtle .shape()

在turtle中默認(rèn)的鼠標(biāo)形狀 可以使用shape()方法來(lái)更改他的形狀,它總共有以下五種形狀:

此函數(shù)用于將 turtle 形狀設(shè)置為具有給定名稱(chēng)的形狀,或者,如果未提供名稱(chēng),則返回當(dāng)前形狀的名稱(chēng)。

用法:

turtle.shape(name=None)

帶有名稱(chēng)的形狀必須存在于Turtle Screen的形狀字典中。最初有以下多邊形形狀:“arrow”,“turtle”,“circle”,“square”,“triangle”,“classic”。這些圖像如下所示。

默認(rèn)值:‘classic’

默認(rèn)形狀:classic

‘arrow’:

arrow

‘turtle’:

turtle

‘circle’:

circle

‘square’:

square

‘triangle’:

triangle

案例

# import package 
import turtle  
  
  
# for default shape 
turtle.forward(100) 
  
# for circle shape 
turtle.shape("circle") 
turtle.right(60) 
turtle.forward(100) 
  
# for triangle shape 
turtle.shape("triangle") 
turtle.right(60) 
turtle.forward(100) 
  
# for square shape 
turtle.shape("square") 
turtle.right(60) 
turtle.forward(100) 
  
# for arrow shape 
turtle.shape("arrow") 
turtle.right(60) 
turtle.forward(100) 
  
# for turtle shape 
turtle.shape("turtle") 
turtle.right(60) 
turtle.forward(100)

效果圖

運(yùn)行效果圖

總結(jié) 

到此這篇關(guān)于Python turtle.shape()用法的文章就介紹到這了,更多相關(guān)Python turtle.shape()用法內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論