【发布时间】:2012-10-24 11:29:42
【问题描述】:
如果我有这样的程序:
def P(x):
# x is an integer
print str(x)
我想要一个输出,例如:
>>> You chose the number: X
其中 X 是在过程 P 中打印的结果。 如何在不更改程序的情况下做到这一点?
如果我这样做:
print 'You chose the number: '
P(x)
我会得到的
You chose the number:
X
我怎样才能让它们在同一行?
【问题讨论】:
标签: python string formatting