Suppress print newline in python 3 str.format

橙三吉。 提交于 2019-12-06 02:40:10

Your problem is that you have the end='' argument being passed to the format function, not to the print function.

Change this line:

print ( '{0:3d} {1:6d} {2:10s} '.format (int1,int2,string1,end=''))

To this:

print ( '{0:3d} {1:6d} {2:10s} '.format (int1,int2,string1), end='')

By the way, you should also give PEP8 a read. It defines standards for Python coding styles, that you really should try to follow, unless you're working with a group of people that have agreed on some other style standards. In particular, your spacing is a bit weird around function calls - you shouldn't have spaces between function names and the argument parentheses, or between the parentheses and the first argument. I wrote my suggested solution to your problem in a way that maintains your current style, but it really should look more like this:

print('{0:3d} {1:6d} {2:10s} '.format(int1, int2, string1), end='')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!