我有以下代码:打印输出
>>> x = 0
>>> y = 3
>>> while x < y:
... print '{0}/{1}, '.format(x+1, y)
... x += 1
输出:
1/3,
2/3,
3/3,
我想我的输出,如:
1/3, 2/3, 3/3
我搜索,发现在单行中做到这一点的方法是:
sys.stdout.write('{0}/{1}, '.format(x+1, y))
有没有另一种方法呢?我对sys.stdout.write()
不太满意,因为我不知道它与print
有什么不同。
哇。谢谢。我把逗号放在里面。 – user225312 2010-07-05 08:35:26