30

Python doc 文字列を記述するための推奨される方法は何ですか?

"""また"

Dive Into Pythonで、著者は次の例を提供しています。

def buildConnectionString(params):
    """Build a connection string from a dictionary of parameters.

    Returns string."""

別ので、著者は別の例を提供しています。

def stripnulls(data):
    "strip whitespace and nulls"
    return data.replace("\00", "").strip()

どちらの構文も機能します。私にとっての唯一の違いは、"""複数行のドキュメントを記述できることです。

それ以外に違いはありますか?

4

3 に答える 3