catalogue
- 1. Parentheses in python ()
- 2. Brackets [] in Python
- 3. Python curly braces {} curly braces
preface:
Python
There are three main data types: dictionary, list and tuple. They are represented by curly brackets, square brackets and small brackets respectively.
For example:
-
Dictionaries:
dic={'a':12,'b':34}
-
List:
list=[1,2,3,4]
-
Tuple:
tup=(1,2,3,4)
python
There are three most common kinds of parentheses in languages: parentheses (), brackets [] and curly braces, also known as curly braces {}. Its functions are also different, which are used to represent differentpython
Basic built-in data type.
1. Parentheses in python ()
representativetuple
Tuple data type, tuple is an immutable sequence. The creation method is very simple. Most of the time, it is enclosed in parentheses.
1
2
3
4
5
6
7
8
9
|
>>> tup = ( 1 , 2 , 3 ) >>> tup ( 1 , 2 , 3 ) >>> >>>() #Empty tuple () >>> >>> 55 , #Tuple of a value ( 55 ,) |
2. Brackets [] in Python
representativelist
List data type. A list is a variable sequence. Its creation method is simple and special,Like the following:
1
2
|
>>> list ( 'python ' ) [ 'p' , 'y' , 't' , 'h' , 'o' , 'n' ] |
3. Python curly braces {} curly braces
representativedict
Dictionary data type. A dictionary is composed of key pair value groups. colon∵
Separate key and value, comma ‘∵
‘separate groups.
The method of creating with braces is as follows:
1
2
3
4
|
>>> dic = { 'jon' : 'boy' , 'lili' : 'girl' } >>> dic { 'lili' : 'girl' , 'jon' : 'boy' } >>> |
This is the end of this article on the detailed explanation of Python’s basic parentheses () [] {}. For more information about Python’s parentheses () [] {}, please search the previous articles of developeppaper or continue to browse the relevant articles below. I hope you will support developeppaper in the future!