+ 1
output formatting using % in Python
x=123 print('The value of x %2.1d ' %x) OUTPUT: 123 But it should be ' 1' as maximum length is two and we want only precision of one
3 Réponses
+ 4
If you want to display the first digit of the number 123:
print('The value of x = %.1s' %x)
+ 1
thanks !
But when I am using %5.5 the output is 00123 ?
0
~ swim ~ have a look at this.