ProgrammingのTipなど

文字列format


数字や文字列などを指定した場所に表示させる関数

"文字列{0}{1}".format(A,B)
で0にAの数字や文字列が1にはBが代入されます
例文
print("number 0 is {0} number 1 is {1}".format(50,8))
>number 0 is 50 number 1 is 8

"文字列{A}{B}".format(A=AAA,B=BBB)

例文
print("A is {a} B is {b} ".format(a="plate",b=8.0))
>A is plate B is 8.0

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Menu

メニュー2

開くメニュー

閉じるメニュー

  • アイテム
  • アイテム
  • アイテム
【メニュー編集】

管理人/副管理人のみ編集できます