Help us understand the problem. What is going on with this article?

#python の文字列埋め込み・連結を進歩させよう ( .format から f-strings へ ) ( #初心者 向け )

More than 1 year has passed since last update.

連結するやつ

first_name = 'Alice'
last_name = 'Liddel'

first_name + ' is ' + last_name
'Alice is Liddel'

なんかちょっとスマートそうな埋め込み

"{} is {}".format(first_name, last_name)
'Alice is Liddel'

辞書で渡して名前付きで埋め込むやつ

可読性が高いよね!たぶん。

"{first_name} is {last_name}".format(**{"first_name":"Alice", "last_name":"Liddell"})
'Alice is Liddell'

f-strings

first_name = "Alice"
last_name = "Liddell"
f"{first_name} is {last_name}"
'Alice is Liddell'

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/1686

YumaInaura
Ruby on Rails 業務経験 約5年 / Perl PHP Python Golang Linux Apache MySQL BigQuery Jenkins ansible AWS など / いなうらゆうま / YumaInaura / 稲浦悠馬
http://twitter.com/yumainaura
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした