Where am I messing up with output formatting?

大兔子大兔子 提交于 2019-12-02 11:39:00

You can't switch back and forth between automatic field numbering - what you get by specifying a simple {} - and manual field specification, e.g. {0}. If you want the same field repeated several times, as 'Word' is in your example, you'll have to also specify what you want the other fields to be. For example, you might want to start with the first argument, 'Word', which is element 0, and the fifth argument, '='*51, as the last, which is element 4:

>>> print("{0}{0:27}{0:39}{0:51}\n{4}".format("Word", "Occurence", "Avg. Score", "Std. Dev.", "="*51))
WordWord                       Word                                   Word

===================================================

You'll have to decide for yourself which arguments you want to be placed where in the format string.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!