5
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 1 year has passed since last update.

トリプルクォーテーション(三重引用符 """)の中に変数を入れる

Last updated at Posted at 2022-11-26

結論、以下のようにf文字列にすればいい。

sample.py
name = 'neko'
sentence = f"""My name is {name}."""
print(sentence)
#My name is neko.

三重引用符だからといって普通の文字列とは大きく違うんじゃないかと
難しく考えてました。
(もちろん仕様など全く同じとは思いませんが)

pythonでMySQLdbライブラリを使っていて
三重引用符の中に変数格納したいな〜と気になったので調査しました。
以上です〜

5
1
2

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
5
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?