剥离小数点的浮点数

发布于 2025-02-05 07:06:02 字数 160 浏览 1 评论 0原文

为什么不可能将小数点从浮子上剥离?

str(1.5).strip(“。”)返回1.5

为什么不返回15

小数点是否与完整的stop 不等的符号?

Why isn't it possible to strip the decimal point off of a float?

str(1.5).strip(".") returns 1.5

Why doesn't it return 15?

Has the decimal point an own symbol that is not equal with the full stop .?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚雾 2025-02-12 07:06:03

str.Strip()仅在开始和结束时删除字符,而不在中间。它主要用于在一系列输入周围删除外部空格(没有参数,默认为删除空格)。

使用str.replace()在任何地方替换字符串:

str(1.5).replace('.', '')

str.strip() only removes characters at the beginning and end, not in the middle. It's mostly used for removing extraneous whitespace around a line of input (with no argument, it defaults to removing whitespace).

Use str.replace() to replace a string anywhere:

str(1.5).replace('.', '')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文