sync notes(auto)
This commit is contained in:
parent
50e306fd7c
commit
1cc6f9361d
1 changed files with 10 additions and 0 deletions
10
content/20240323192523 pythonのf-string.md
Normal file
10
content/20240323192523 pythonのf-string.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# 20240323192523 pythonのf-string
|
||||||
|
#python
|
||||||
|
## 基本的な使いかた
|
||||||
|
`{}`をplacefolderとして文字列に
|
||||||
|
"{} {} {}".format(a, b, c) とかやって変数を埋めこめる機能。 [rubyの式展開](https://docs.ruby-lang.org/ja/latest/doc/spec=2fliteral.html#exp) 、[javascriptの テンプレートリテラル](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Template_literals)などにも近いが、
|
||||||
|
細かい書式指定なども可能なため、Cの[printfのフォーマット指定](https://ja.wikipedia.org/wiki/Printf#%E6%9B%B8%E5%BC%8F%E5%8C%96%E6%96%87%E5%AD%97%E5%88%97)が一番近いかもしれない。といいつつ、現状だとそこまで色々使っていないかも。
|
||||||
|
参考サイトの説明が詳しい。
|
||||||
|
|
||||||
|
## Ref.
|
||||||
|
- [Pythonのf文字列(フォーマット済み文字列リテラル)の使い方 | note.nkmk.me](https://note.nkmk.me/python-f-strings/)
|
Loading…
Reference in a new issue