本节内容如下:
显示格式
实例
显示格式
实例
a=1000 print('a = %d' % a) # a = 1000 print('a = %i' % a) # a = 1000 print('a = %u' % a) # a = 1000 print('a = %o' % a) # a = 1750 print('a = %x' % a) # a = 3e8 print('a = %x' % a) # a = 3e8 b = 3.14 print('b = %e' % b) # b = 3.140000e+00 print('b = %e' % b) # b = 3.140000e+00 print('b = %3.2f' % b) # b = 3.14 print('b = %3.2f' % b) # b = 3.14 b = 3.14e3 print('b = %g' % b) # b = 3140 print('b = %g' % b) # b = 3140