简体   繁体   English

Python:整数前的点是什么意思?

[英]Python: What does a dot before an integer mean?

I was reading some Python code:我正在阅读一些 Python 代码:

math.ceil(.1) + math.floor(.1)

and have encountered the following notation - .1 .并且遇到了以下符号 - .1

Could someone explain what does it mean?有人能解释一下是什么意思吗?

Thanks in advance.提前致谢。

The integer is a float (decimal) value整数是一个浮点(十进制)值

>>> .1
0.1
>>> 1
1

As Shashank V 's answer notes , one can can check the type of an object by calling type() on it!正如Shashank V的回答所指出的,可以通过调用type()来检查对象的type()

>>> type(.1)
<class 'float'>
>>> a = .1
>>> type(a)
<class 'float'>

.1 是一个浮点数,相当于 0.1

It's a float.这是一个浮动。 .1 represent the decimal value 0.1 .1代表十进制值0.1

>>> type(.1)
<class 'float'>

https://docs.python.org/3/tutorial/floatingpoint.html https://docs.python.org/3/tutorial/floatingpoint.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM