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来处理格式化数据

原文地址:https://www.cnblogs.com/javametro/p/6859348.html