Python 内置函数 —— format

  • 科学计数法:

    >> format(2**20, '.2e')
    '1.05e+06'
  • 小数 ⇒ 百分数

    >> format(.1234, '.1%')
    12.3%
原文地址:https://www.cnblogs.com/mtcnn/p/9423067.html