Python 3.x 如何使用print()在变量前面添加字符

Python 3.x 如何使用print()在变量前面添加字符,python-3.x,Python 3.x,我不熟悉使用3.7的Python,我试图在整数变量前面添加一个“$”。在执行了许多搜索之后,他们似乎有很多方法来格式化字符串。我的目标是在print()中添加一个“$” 我尝试了打印('Total amount is',house amount',of the house',sep='$)。但是没有运气 代码: 结果: House amount is $300000 for the house. HOA amount for the house is $550.4 every year pri

我不熟悉使用3.7的Python,我试图在整数变量前面添加一个“$”。在执行了许多搜索之后,他们似乎有很多方法来格式化字符串。我的目标是在print()中添加一个“$”

我尝试了
打印('Total amount is',house amount',of the house',sep='$)
。但是没有运气

代码:

结果

House amount is $300000 for the house. HOA amount for the house is $550.4 every year
print(“房屋金额为${}房屋的HOA金额为${}每年”。格式(房屋金额,HOA))

请记住,它会按顺序执行这些操作。

“在执行了多次搜索之后,它们似乎有许多格式化字符串的方法。”您是否专门搜索了问题中的标题?通过谷歌搜索你的标题(前面有“python”)发现了这一点:/谢谢你的回复TrebledJ,我会记住这一点,以备将来的帮助!
House amount is $300000 for the house. HOA amount for the house is $550.4 every year