In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you what are the relevant knowledge points about the built-in data types in Python language, which are detailed in content and clear in logic. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Foreword:
Computers can handle various types of data, including numerical values and text. Different data belong to different data types and support different operations. Python language provides rich built-in data types. Used to deal with various types of data effectively. In Python, everything is an object. Each object belongs to a product of some data type.
1. Numerical data type 1. Integer type
Integer objects support relational operations, arithmetic operations, bit operations, built-in functions, math modules, and so on.
Unlike other languages, integers in Python can be of any length (limited only to computer memory).
Integer objects are immutable.
① integer object
Direct assignment:
Create objects directly:
Use the int () built-in function to create an object directly, and you can also specify a decimal number, but the object being created is a string that conforms to the numeric format.
Binary digit
Operators supported by ②
There are several special operators in Python3, which will be listed one by one next.
The result of the expression shows that the single division sign 5max 41.25 will be divided by the decimal 5Universe 41 (which can be thought of as a forced division). The two multiplicative signs represent the exponent, followed by the exponent 2. Boolean type
(used to represent Boolean logical values) contains only two values True and False
① bool object
Non-zero non-empty or True:
Operators supported by ③
Operator states that the priority not logic non-Operand is True, the result is Falseand logic and two operands are True, the result is Trueor logic, or one Operand is True, then the result is True
It is worth noting that both and and or operands have a short-circuit mechanism, and if the result can be judged by the first number, the second number will not be judged.
3. Floating point type
Floating point numbers are data types that represent real numbers and correspond to single and double precision types in other computer languages.
The precision of the Python floating point type is related to the system.
As shown in the figure, the floating point type can omit 0 if there is nothing on the left and right sides of the decimal point. Infinity stands for infinity for Python. Nan stands for non-numeric value. Floating point numbers, like integers, are supported by packages such as math in Python.
4. Plural type
(used to represent plural) plural has real and imaginary parts and is one of the built-in data types of Python. Users can create object instances of type complex.
As shown in the figure, the data type of the complex number is complex, including the real part and the imaginary part. You can use real to get the real part, use imag to get its imaginary part, and use conjugate to get its conjugate complex number. Of course, complex numbers support arithmetic operations as well as integers, and are also supported by the cmath package.
2. Sequence data types
Sequence data types represent several ordered data.
1. Immutable sequence name keywords example string str "Hello world" tuple type tuple (1, "3"), (1,) byte sequence bytesb'abc'2. Variable sequence name keyword example list type list ["hello", "world"] byte array bytearray can modify byte array 3, collection data type
The collection data type represents a collection of several data, and the data items are not ordered and do not repeat.
Set (set)
Immutable set (frozenset)
Fourth, dictionary data type
The dictionary data type is used to represent a dictionary of key-value pairs. The built-in dictionary data type of Python is dict
5. NoneType, NotImplementedType, EllipsisType1.NoneType
The NoneType data type contains a unique value None, which is mainly used to represent null values, such as the result of a function that does not return a value.
2.NotImplementedType
The NotImplementedType data type contains the unique value NotImplemented. In the process of numerical operation and comparison
This value may be returned if the object does not support it during the operation.
3.EllipsisType
The EllipsisType data type contains a unique value Ellipsis, which means that the string symbol "..." is omitted.
VI. Other data types
For Python, everything is an object, but every object has a data type, and modules, classes, objects, and functions all belong to some data type. The Python interpreter contains built-in types such as code objects, frame objects, trace objects, slice objects, static method objects, and class method objects.
That's all of the article "what are the built-in data types in the Python language?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.