turtle 模塊以麵向對象和麵向過程的方式提供 turtle 圖形基元。由於它使用Tkinter作為基礎圖形,因此需要安裝有Tk支持的Python版本。
turtle .write_docstringdict()
此方法用於創建docstring-dictionary並將其寫入文件。
用法:
turtle.write_docstringdict(filename='turtle_docstringdict')
必須顯式調用( turtle 圖形類不使用)。 docstring字典將被寫入Python腳本<filname> .py。它旨在用作將文檔字符串翻譯成不同語言的模板。
下麵是上述方法的實現示例:
Python3
# importing package
import turtle
# making docstringdictionary file
turtle.write_docstringdict(filename='turtle_docstringdict')
輸出:
在這裏,我們可以看到一個名稱為“turtle_docstringdict.py”的輸出文件,其中存儲了有關龜方法的示例說明。所有內容都以字典(鍵值對)的形式存儲,其中:
- 鍵:方法名稱
- 值:舉例說明
相關用法
- Python Wand function()用法及代碼示例
- Python tell()用法及代碼示例
- Python id()用法及代碼示例
- Python map()用法及代碼示例
- Python dir()用法及代碼示例
- Python cmp()用法及代碼示例
- Python int()用法及代碼示例
- Python ord()用法及代碼示例
- Python hex()用法及代碼示例
- Python now()用法及代碼示例
- Python oct()用法及代碼示例
- Python str()用法及代碼示例
- Python sum()用法及代碼示例
- Python seek()用法及代碼示例
- Python reversed()用法及代碼示例
注:本文由純淨天空篩選整理自deepanshu_rustagi大神的英文原創作品 turtle.write_docstringdict() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。