How to print without a space

This question already has an answer here:

  • How to print without newline or space? 26 answers
  • How do I keep Python print from adding newlines or spaces? [duplicate] 16 answers

  • 这对你有用吗?

    import sys
    sys.stdout.write(item)
    

    Before the wonderful end= (and sep= ) appeared in Python 3, I used to build up lines within strings and the print out the string in one hit:

    str = "Three integers:"
    for iii in range (3):
        str = "%s %d" % (str, iii)
    print s
    

    Needless to say, I don't code in Python 2 any more :-)

    链接地址: http://www.djcxy.com/p/77224.html

    上一篇: Python中奇怪的换行符错误

    下一篇: 如何在没有空间的情况下打印