001、 格式化数值
>>> "{:.2%}".format(0.123456789) '12.35%' >>> "{:.5%}".format(0.123456789) '12.34568%' >>> "{:.2}".format(0.123456789) '0.12' >>> "{:.5}".format(0.123456789) '0.12346'
002、格式化字符串
>>> "{}".format("Python") 'Python' >>> "xx{}yy".format("Python") 'xxPythonyy' >>> "xx{}yy".format("kkkk") 'xxkkkkyy'