python字符串格式化【format】

format的用法:

==============================================

      print("内容是{}","长度是{}".format("abc",len("abc")))

      #输出结果:

               内容是abc,长度是3

=====================================================================================

      print("内容是{1}","长度是{0}".format("abc",len("abc")))

      #输出结果

               内容是3,长度是abc

======================================================================

    print("内容是{c}","长度是{l}".format(l="abc",c=len("abc")))

      #输出结果

               内容是3,长度是abc

posted @ 2017-12-27 21:13  Justice-V  阅读(89)  评论(0)    收藏  举报