如何在 Python 中将带点和逗号的字符串转换为浮点数
问题描述
如何在 Python 中将像 123,456.908 这样的字符串转换为浮点 123456.908?
How can I convert a string like 123,456.908 to float 123456.908 in Python?
解决方案
只需用 replace() 去掉 ,:
float("123,456.908".replace(',',''))
相关文章