python输出不换行
Python2的写法是:
print 'hello',
Python3的写法是:
print('hello', end='')
对于python2和python3都兼容的写法是:
from __future__ import print_function
print('hello', end='')
本文介绍了如何在Python中实现不换行输出。针对Python2和Python3的不同版本提供了具体的代码示例,并提供了一种兼容两个版本的方法。
Python2的写法是:
print 'hello',
Python3的写法是:
print('hello', end='')
对于python2和python3都兼容的写法是:
from __future__ import print_function
print('hello', end='')

被折叠的 条评论
为什么被折叠?