# Python CodeRecipe|join()の使い方

Home String Methods

# join()の例1

Join all items in a tuple into a string, using a hash character as separator:

    myTuple = ("John", "Peter", "Vicky")x = "#".join(myTuple)

# join()の定義及び使い方

join()関数は反復可能なすべての項目を取ります。 1つの文字列に結合します。 セパレータとして文字列を指定する必要があります。

# join()の構文


# join()の引数

パラメータ 説明

iterable 必須. Any iterable object where all the returned values are strings

# Example

Join all items in a dictionary into a string, using a the word "TEST" as separator:

    myDict = {"name": "John", "country": "Norway"}mySeparator = "TEST"x 
    = mySeparator.join(myDict)print(x)

Note: When using a dictionary as an iterable, the returned values are the keys, not the values.

Home String Methods