【发布时间】:2014-08-19 03:06:54
【问题描述】:
我希望打印 new balance 的 2 行位于同一行,而不是 2 个单独的行。我该怎么做?
def main():
# Initial balance
balance = input ('Wallet balance: ')
# Withdraw amount from wallet balance
withdraw = input ('Withdraw amount: ')
# Withdraw process and new balance display
if withdraw > 0:
new = balance - withdraw
print ('Your new balance: ')
print new
main()
【问题讨论】:
-
你要完成的任务很简单,如上所述通过使用',' x = "123" y = "456" print x,y 问题通常是当你使用一个循环,在它里面你想使用打印。然后为了在一行中获得输出,您可以执行以下操作: import sys for i in "123456": sys.stdout.write(i) 并在一行中得到它。
标签: python formatting output python-2.x