How python converts an integer or numeric string to a floating point number
This article will explain in detail how python converts an integer or numeric string into a floating point number. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Convert to floating point type
Convert an integer or numeric string to a floating point number
In [1]: float (3) Out [1]: 3.012
If it cannot be converted to a floating point number, it will report ValueError:
In [2]: float ('a') # ValueError: could not convert string to float: 'what are the data types of a'python? data types of python: 1. Numeric types, including int (integer), long (long integer), and float (floating point). two。 String, which is of type str and type unicode, respectively. 3. Boolean, Python Boolean is also used for logical operations and has two values: True (true) and False (false). 4. List, the list is the most frequently used data type in Python, and any data type can be placed in the collection. 5. Tuples are identified by "()", and internal elements are separated by commas. 6. A dictionary is a collection of key-value pairs. 7. A collection is an unordered, non-repeating combination of data.
On "python how to convert an integer or numeric string into a floating point number" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.