# Python CodeRecipe|zfill()の使い方

Home String Methods

# zfill()の例1

Fill the string with zeros until it is 10 characters long:

    txt = "50"x = txt.zfill(10)print(x)

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

zfill()関数は、 指定された長さに達するまで、文字列の先頭。 lenパラメータの値が文字列の長さより短い場合、 充填が完了しました。

# zfill()の構文

string.zfill(len)

# zfill()の引数

パラメータ 説明

len 必須. A number specifying the position of the element you want to remove

# zfill()の例2

Fill the strings with zeros until they are 10 characters long:

    a = "hello"b = "welcome to the jungle"c = "10.000"print(a.zfill(10))print(b.zfill(10))print(c.zfill(10))

Home String Methods