[英]Stripping decimal point of floating point number
Why isn't it possible to strip the decimal point off of a float?为什么不能去掉浮点数的小数点?
str(1.5).strip(".")
returns 1.5
str(1.5).strip(".")
返回1.5
Why doesn't it return 15
?为什么不返回15
?
Has the decimal point an own symbol that is not equal with the full stop .
小数点有自己的符号,不等于句号.
? ?
str.strip()
only removes characters at the beginning and end, not in the middle. str.strip()
只去除开头和结尾的字符,不去除中间的字符。 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.replace()
替换任意位置的字符串:
str(1.5).replace('.', '')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.