小编Car*_*ell的帖子

如何格式化 f 字符串中的字符串和变量?

我试图将“$”和totalTransactionCost 移至该字段的右侧。

我当前的代码是:print(f"Total Cost Of All Transactions: ${totalTransactionCost:>63,.2f}")

该代码能够将totalTransactionCost 移至字段的右侧,但如何也包含“$”?

python f-string

3
推荐指数
1
解决办法
131
查看次数

标签 统计

f-string ×1

python ×1