强大的format使用

获取数字或者年月 不够2位时补全

    def get_ad_name(cls):
        random = cls._get_random_int()
        month, day =(str(i) for i in cls._get_date_detail())
        return "{month:0>2s}{day:0>2s}{random}".format_map(vars())

保留2位小数

  return "{month:.2f}.format(0.234565667)

  

posted @ 2022-06-16 11:26  JakeTan  阅读(27)  评论(0)    收藏  举报