String formatting: % vs. .format vs. string literal

后端 未结 16 2730
青春惊慌失措
青春惊慌失措 2020-11-21 04:18

Python 2.6 introduced the str.format() method with a slightly different syntax from the existing % operator. Which is better and for what situations?

Pyt

16条回答
  •  半阙折子戏
    2020-11-21 04:51

    PEP 3101 proposes the replacement of the % operator with the new, advanced string formatting in Python 3, where it would be the default.

提交回复
热议问题