w = 1 print('%.2f' %w) print('{:.2f}'.format(w)) 输出 1.00 1.00 python中 “{:.2f}”和“%.2f”的区别_imredboy的博客-CSDN博客