【发布时间】:2022-09-29 22:10:31
【问题描述】:
我以字符串格式接收数据:
input1 = \",1\"
input2 = \"1,\"
我需要将它转换为浮点数并在我的测试中验证它。 我期待这种转换:
\",1\" -> 0.1
\"1,\" -> 1.0
不使用正则表达式可以吗?
-
这回答了你的问题了吗? Formatting floats without trailing zeros
-
有关详细信息,请参阅this answer(否则问题标题会产生误导)。
标签: python