shivency

1、输出格式化/多个输出格式化

1 x= 4
2 y= 12.5
3 
4 print \'the rabbit is %d\',x
5 print \'the rabbit is %d years old\',x
6 print \'%f is average\',y
7 print \'%f * %d\' %(y,x)
8 print \'%f * %d is %f\' %(y, x, y*x)

4~6行是输出格式化,7~8行为多个输出格式化

下面是结果

1 the rabbit is %d 4
2 the rabbit is %d years old 4
3 %f is average 12.5
4 12.500000 * 4
5 12.500000 * 4 is 50.000000


然后有两个问题:

1、为什么python中字符串乘负数会为空字符串而不报错?

2、如何输出格式化使%8,打印出0008?

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2022-01-02
  • 2021-11-02
  • 2021-10-21
猜你喜欢
  • 2022-12-23
  • 2021-08-22
  • 2021-09-22
  • 2022-01-25
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案