>>> income = 50
>>> print("Your income tax is $",income,".")
Your income tax is $ 50 .
那么如何打印" 50美元。"一起?
答案 0 :(得分:1)
您可以使用sep
参数进行打印:
>>> income = 50000
>>> print("Your income tax is $", income, ".", sep='')
Your income tax is $50000.
或使用str.format
:
>>> print("Your income tax is ${}.".format(income))
Your income tax is $50000.
答案 1 :(得分:0)
print("Your income tax is ${0}.".format(income))
答案 2 :(得分:0)
您也可以这样做:
x = 50
x = str(x)
y = 'Your Income is $'
z='.'
print(y+x+z)
输出: 你的收入是50美元。