Python 3.x下消除print()自动换行
Python 2.x下的print语句在输出字符串之后会默认换行,如果不希望换行,只要在语句最后加一个“,”即可。但是在Python 3.x下,print()变成内置函数,加“,”的老方法就行不通了。 查询Python的Library Reference>Built-in Functions,找到如下 条目 : “ print ( [ object , ... ], * , sep=' ' , end='\n' , file=sys.stdout ) Print object (s) to the stream file , separated by sep and followed by end . sep , end and file , if present, must be given as keyword arguments. All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end . Both sep and end must be strings; they can also be None , which means to use the default