turtle 模塊以麵向對象和麵向過程的方式提供 turtle 圖形基元。由於它使用Tkinter作為基礎圖形,因此需要安裝有Tk支持的Python版本。
turtle .clearstamp()
turtle.clearstamp()方法用於刪除所有或全部前n個郵票。此方法需要一個整數參數。因此,帶有id的印章將被清除。
用法:turtle.clearstamp(stampid)
參數:
stampid-整數,必須為先前的stamp()調用的返回值。
下麵是上述方法的實現和一些示例:
範例1:
Python3
# import package
import turtle
# set turtle speed to slowest
# for better understandings
turtle.speed(1)
# motion with stamps
# and their ids
turtle.forward(50)
id1 = turtle.stamp()
turtle.forward(50)
id2 = turtle.stamp()
turtle.forward(50)
id3 = turtle.stamp()
# hide the turtle to
# clarify stamps
turtle.ht()
# clear the stamps
# of id:id1 and id3
turtle.clearstamp(id1)
turtle.clearstamp(id3)
輸出:
範例2:
Python3
# import package
import turtle
# list to store ids
ids = []
# loop to create motion
# with stamps
for i in range(12):
# motion
turtle.forward(50)
# stampid
id = turtle.stamp()
lst.append(id)
turtle.right(30)
# hide the turtle for
# better understandings
turtle.ht()
# loop for clear stamps with
# their ids using clearstamp
# half stamps are cleared
for i in range(len(lst)//2):
turtle.clearstamp(lst[i])
輸出:
相關用法
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python PIL ImageChops.add()用法及代碼示例
- Python os.mkfifo()用法及代碼示例
- Python PIL copy()用法及代碼示例
- Python sympy.lcm()用法及代碼示例
- Python sympy.gcd()用法及代碼示例
- Python PIL composite()用法及代碼示例
- Python sympy.crt()用法及代碼示例
- Python os.fsync()用法及代碼示例
- Python os.lchflags()用法及代碼示例
- Python os.mknod()用法及代碼示例
- Python os.symlink()用法及代碼示例
- Python os.fsdecode()用法及代碼示例
- Python os.truncate()用法及代碼示例
- Python os.ftruncate()用法及代碼示例
- Python os.setgroups()用法及代碼示例
注:本文由純淨天空篩選整理自deepanshu_rustagi大神的英文原創作品 turtle.clearstamp() method in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。