python format

python的格式化操作使用format函数来处理

其中{:d}代表十进制数据

 

if Robot.population == 0:
                        print("{} was the last one.".format(self.name))
                else:
                        print("There are still {:d} robots working".format(Robot.population))

 

可以丰富的使用python format来处理格式化数据

posted @ 2017-05-16 04:08  专属9号  阅读(149)  评论(0编辑  收藏  举报