Python 3 bytes formatting

前端 未结 6 830
情书的邮戳
情书的邮戳 2020-12-05 22:41

In Python 3, one can format a string like:

\"{0}, {1}, {2}\".format(1, 2, 3)

But how to format bytes?

b\"{0}, {1}, {2}\".fo         


        
6条回答
  •  借酒劲吻你
    2020-12-05 23:05

    Another way would be:

    "{0}, {1}, {2}".format(1, 2, 3).encode()
    

    Tested on IPython 1.1.0 & Python 3.2.3

提交回复
热议问题