64
30

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 5 years have passed since last update.

フォーマット文字列内での波括弧のエスケープ

Last updated at Posted at 2013-06-29

Pythonでフォーマット文字列を使用する場合,波括弧をプレースホルダの指定に使用する.
波括弧自体を文字列として使用したい場合, 以下のように波括弧を重ねる必要がある.

波括弧のエスケープ
>>> 'test {{{0}}}'.format('hoge')
'test {hoge}'

バックスラッシュではエスケープできないので注意.

(ref) http://docs.python.org/2.7/library/string.html#formatstrings

64
30
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
64
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?