Help on class float in module __builtin__:
class Float (object)
| Floating point number, float (x)
|
| Convert a string or number to a floating point number, if possible.
|
| Methods defined here:
|
| __abs__ (...)
| x.__abs__ () <==> ABS (x)
|
| __add__ (...)
| x.__add__ (y) <==> x+y
|
| __coerce__ (...)
| x.__coerce__ (y) <==> coerce (x, y)
|
| __div__ (...)
| x.__div__ (y) <==> x/y
|
| __divmod__ (...)
| x.__divmod__ (y) <==> divmod (x, y)
|
| __eq__ (...)
| x.__eq__ (y) <==> x==y
|
| __float__ (...)
| x.__float__ () <==> float (x)
|
| __floordiv__ (...)
| x.__floordiv__ (y) <==> x//y
|
| __format__ (...)
| Float.__format__ (Format_spec), string
|
| Formats the float according to Format_spec.
|
| __ge__ (...)
| x.__ge__ (y) <==> x>=y
|
| __getattribute__ (...)
| x.__getattribute__ (' name ') <==> x.name
|
| __getformat__ (...)
| Float.__getformat__ (TYPESTR), string
|
| You probably don ' t want the use of this function. It exists mainly to be
| Used in Python ' s test suite.
|
| Typestr must be ' double ' or ' float '. This function returns whichever of
| ' Unknown ', ' IEEE, Big-endian ' or ' IEEE, Little-endian ' best describes the
| Format of floating point numbers used by the C type named by Typestr.
|
| __getnewargs__ (...)
|
| __gt__ (...)
| x.__gt__ (y) <==> x>y
|
| __hash__ (...)
| x.__hash__ () <==> hash (x)
|
| __int__ (...)
| x.__int__ () <==> int (x)
|
| __le__ (...)
| x.__le__ (y) <==> x<=y
|
| __long__ (...)
| x.__long__ () <==> long (x)
|
| __lt__ (...)
| x.__lt__ (y) <==> x<y
|
| __mod__ (...)
| x.__mod__ (y) <==> x%y
|
| __mul__ (...)
| x.__mul__ (y) <==> x*y
|
| __ne__ (...)
| x.__ne__ (y) <==> x!=y
|
| __neg__ (...)
| x.__neg__ () <==>-X
|
| __nonzero__ (...)
| x.__nonzero__ () <==> x! = 0
|
| __pos__ (...)
| X.__pos__ () <==> +x
|
| __pow__ (...)
| x.__pow__ (y[, z]) <==> pow (x, y[, z])
|
| __radd__ (...)
| x.__radd__ (y) <==> y+x
|
| __rdiv__ (...)
| x.__rdiv__ (y) <==> y/x
|
| __rdivmod__ (...)
| x.__rdivmod__ (y) <==> divmod (y, x)
|
| __repr__ (...)
| x.__repr__ () <==> repr (x)
|
| __rfloordiv__ (...)
| x.__rfloordiv__ (y) <==> y//x
|
| __rmod__ (...)
| x.__rmod__ (y) <==> y%x
|
| __rmul__ (...)
| x.__rmul__ (y) <==> y*x
|
| __rpow__ (...)
| y.__rpow__ (x[, z]) <==> pow (x, y[, z])
|
| __rsub__ (...)
| x.__rsub__ (y) <==> y-x
|
| __rtruediv__ (...)
| x.__rtruediv__ (y) <==> y/x
|
| __setformat__ (...)
| Float.__setformat__ (Typestr, FMT), None
|
| You probably don ' t want the use of this function. It exists mainly to be
| Used in Python ' s test suite.
|
| Typestr must be ' double ' or ' float '. FMT must be one of ' unknown ',
| ' IEEE, Big-endian ' or ' IEEE, Little-endian ', and in addition can is only
| One of the latter if it appears to match the underlying C reality.
|
| Overrides the automatic determination of c-level floating point type.
| This affects how floats is converted to and from binary strings.
|
| __str__ (...)
| X.__STR__ () <==> str (x)
|
| __sub__ (...)
| x.__sub__ (y) <==> x-y
|
| __truediv__ (...)
| x.__truediv__ (y) <==> x/y
|
| __trunc__ (...)
| Returns the Integral closest to x between 0 and X.
|
| As_integer_ratio (...)
| Float.as_integer_ratio () (int, int)
|
| Returns a pair of integers, whose ratio is exactly equal to the original
| float and with a positive denominator.
| Raises overflowerror on Infinities and a valueerror on NaNs.
|
| >>> (10.0). As_integer_ratio ()
| (10, 1)
| >>> (0.0). As_integer_ratio ()
| (0, 1)
| >>> (-.25). As_integer_ratio ()
| (-1, 4)
|
| Conjugate (...)
| Returns self, the complex conjugate of any float.
|
| Fromhex (...)
| Float.fromhex (string), float
|
| Create a floating-point number from a hexadecimal string.
| >>> float.fromhex (' 0x1.ffffp10 ')
| 2047.984375
| >>> float.fromhex (' -0x1p-1074 ')
| -4.9406564584124654e-324
|
| Hex (...)
| Float.hex (), string
|
| Return a hexadecimal representation of a floating-point number.
| >>> ( -0.1). Hex ()
| ' -0x1.999999999999ap-4 '
| >>> 3.14159.hex ()
| ' 0x1.921f9f01b866ep+1 '
|
| Is_integer (...)
| Returns True If the float is an integer.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| Imag
| The imaginary part of a complex number
|
| Real
| The real part of a complex number
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __new__ = <built-in method __new__ of type object>
| T.__NEW__ (S, ...)-A new object with type S, a subtype of T
Filter (function, iterable)
Construct a list from those elements of iterable for which function returns TRUE. Iterable May is either a sequence, a container which supports iteration, or an iterator. If iterable is a string or a tuple, the result also have that type; Otherwise it is always a list. If function is a None, the identity function is assumed, which is, and all elements of iterable that is false is removed.
Note that the filter (function, iterable) is equivalent to [item for item ' in Iterable if function (item)] If function was not Non E and [item for item in Iterable if Item] if function is None.
See Itertools.ifilter () and Itertools.ifilterfalse () for iterator versions of this function, including a variation that fi Lters for elements where the function returns FALSE.
English Description:
This function is to convert a string or an integer to a floating-point number. If the parameter x is a string, then only the number string represented by decimal is used, and the number can be preceded by a symbol to indicate a positive or negative amount. If the parameter x is an integer, it can be converted to a floating-point number representation. However, there is a special place for this function, which is to use the infinity or inf to represent an infinite number. For example +inf is positive infinity,-inf is negative infinity.
>>> Float (6)
6.0
>>> float (' 6 ')
6.0
>>> float ()
0.0
>>> float (' +5.778 ')
5.778
>>> float ('-5.778 ')
-5.778
>>> float (' +inf ')
Inf
>>> float ('-inf ')
-inf
>>> float (' nan ')
Nan
>>> class T:
... def __init__ (Self,score):
... self.score = Score
... def __float__ (self):
... return Self.score
...
>>> x=t (10.68)
>>> Float (x)
10.68
This article is from the "Big Cloud Technology" blog, please be sure to keep this source http://hdlptz.blog.51cto.com/12553181/1900118
Python built-in function 5-float ()