我想将 php 代码转换为 python3。
这是我的 php 代码
echo "<td class='text-left'>".number_format($amount,2)."</td>";
我想把这个 php 转换成 Python。请帮助我
最佳答案
import locale
def number_format(num, places=0):
return locale.format_string("%.*f", (places, num), True)
使用:
print(number_format(12345.6789, 2))
结果:
12345.68
关于php - 如何将 php number_format() 函数转换为 python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56748268/