多行文档字符串
有时单行文档字符串就足够了,但如果函数更复杂或包含多个参数,一般更适合使用多行文档字符串。
您将通过为之前创建的 clean_text() 函数编写一段多行文档字符串来练习这一点。
本练习是课程的一部分
Python 中级:面向开发者
交互式实操练习
通过完成这段示例代码来试试这个练习。
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()