Data types are an important part of programming languages, and I know that the benefits of having data types are: In memory, the format is known to specify what kinds of operations are available.
My buried point: why have data types
So what are the types of data in Python?
Object type |
Example Constants/Creation |
Digital |
1234,3.1343,3+4j,decimal,fraction |
String |
' Spam ', ' Guido ', ' B ' a\xolc ' |
List |
[1, [2, ' Three '], 4] |
Dictionary |
{' food ': ' spam ', ' taste ': ' Yum '} |
Meta-group |
(1, ' spam ', 4, ' U ') |
File |
Myfile=open (' eggs ', ' r ') |
Collection |
Set (' abc '), {' A ', ' B ', ' C '} |
Other types |
Type, None, Boolean |
Programming Unit |
Functions, modules, classes |
Implementation-related types |
Compiling code Stack Maintenance |
In addition, there are pattern variables associated with regular expressions, and socket objects that are programmed at the network.
Here you can read a little bit:
Number: This is needless to say, almost every programming language will have numbers, this is the most basic, it seems that Python's number type is quite many, there are plural and fractional;
String: Fortunately there is a string type, in my experience of losing programming, no string type of language really uncomfortable, because many programming scenarios will involve the processing of strings I guess there's 20%~30%, I'm guessing;
File: This I feel okay, nothing special, each language on the file this type will be encapsulated;
As for lists, dictionaries, Ganso, collections This type of data is equivalent to the data structure of the commonly used arrays, linked lists, maps have been encapsulated as a tool for you, like Java inside the List,map,set, and this tool should be optimized, than you go to your own data structure one is a ready-made tool, and secondly is guaranteed, Sunline is the system provides generally faster than you, the bad place is that you take the time to learn its operation, and then it is not unable to play their own arbitrary;
Other types: Type, Java has a class object, do not know is not similar; None, is it null; Boolean is TRUE or False
Programming units: Large programs tend to be split into different components, functions, modules, and classes are Python's units, just like the jar package is a Java unit;
Implementation-related types: Smjbwye, I don't understand.
Well, Python has learned half the day, and I've been talking about it for the most part.
This article has no code,
Python Learning (ii) core data types in Python