How to make equal space between words - python -


(sorry bad english) im working @ cmd. want thing:

file_name              dir file_name_3            dir file_name_545          dir file_name_llk          dir 

instead of doing thing:

file_name          dir file_name_3          dir file_name_545          dir file_name_llk          dir 

i tryied in loop:

print data.ljust((20 - len(data) + 20)) if len(data) <= 20 else (data[0:17] + '...').ljust(20)), 'dir' 

but thing not working becase there letters bigger another, 'ljust' words makes not possible.

use format strings.

"{:20}{}".format(data,"dir") 

the same ljkust()

data.ljust(20) + "dir" 

see help(str.ljust) understand ljust


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -