LoginSignup
2
1

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ライブラリを使っていて
三重引用符の中に変数格納したいな〜と気になったので調査しました。
以上です〜

2
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
2
1