What is the difference between width and precision in Python string format in case of strings -
what difference between width , precision in python string format in case of strings?
i mean smth this
'%5.5s'
precision interpreted maximum length, width minimum length:
>>> '%5.5s' % 'foobar' 'fooba' >>> '%5.3s' % 'foobar' ' foo' >>> '%3.5s' % 'foobar' 'fooba'
foobar
truncated fit in 5 , 3 character maximum length, respectively. truncated string fit 5 , 3 character wide column (which can overflow).
python python-2.7
No comments:
Post a Comment