多行 docstring
有時單行的 docstring 就夠了;但如果你的函式較為複雜,或有多個引數,通常改用多行 docstring 會更好。
你將為之前建立的 clean_text() 函式撰寫一個多行 docstring,來練習這項技巧。
本練習屬於課程
Intermediate Python for Developers
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
def clean_text(text, lower=True):
# Add a multi-line docstring
"""
____
"""
clean_text = text.replace(' ', '_')
if lower == False:
return clean_text
else:
return clean_text.lower()