0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pythonで数値などを文字列にくっつけるまとめ

Last updated at Posted at 2021-07-21

ざっくりまとめ&リンク集的なものです。

下の「コードの例」はresultが文字列型なら "今回の結果は: " + resultでうまくいくやつです。

方法名 コードの例 詳しいことが書いてあるページ
キャスト "今回の結果は: " + str(result) -
f文字列 f"今回の結果は: {result}" https://note.nkmk.me/python-f-strings/
フォーマット関数 "今回の結果は: {}".format(result) https://www.atmarkit.co.jp/ait/articles/1904/23/news015_4.html
書式化演算子 "今回の結果は: %s" % (result) https://www.javadrive.jp/python/string/index23.html

最近、研修中に見かけたんですが、コードの最中にstr = 1みたいなことを書くとstr(1)みたいなことができなくなるんで注意ですね。

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?