0
0

More than 1 year has passed since last update.

【忘備録】python  f-strings

Posted at

Python 3.6よりformatではなく、f-stringsが以下のように使えるようになった。
こちらのほうが処理速度が速いらしい。

a = 'a'
print(f'a is {a}')
# 結果 a is a
 
x, y, z = 1, 2, 3
print(f'a is {x}, {y}, {z}')
print(f'a is {z}, {y}, {x}')

# 結果 a is 1, 2, 3
# 結果 a is 3, 2, 1
 
name = 'Jun'
family = 'Sakai'
print(f'My name is {name} {family}. Watashi ha {family} {name}')

#結果 My name is Jun Sakai. Watashi ha Sakai Jun

0
0
0

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
0