present (sb for a job etc)
The three most common types of parentheses in the Python language are: parentheses (), braces [], and braces {}; they serve different purposes, and are used to represent different basic Python built-in data types.
parentheses ( )
Parentheses () in Python:
Represents the tuple meta-ancestor datatype; a meta-ancestor is an immutable sequence.
typical example
>>> a = (12,23) >>> a (12, 23) >>> () #Empty Metamorphosis () >>> 1, # The meta-ancestor of a value (1,)
Brackets []
The center bracket [] in Python:
Represents the list datatype, a list is a variable sequence.
typical example
>>> list('home') ['h', 'o', 'm', 'e']
An example of a two-dimensional list is shown below:
list_sample = [['IBM','Apple','Lenove'],['America','China']]
The list is accessed by an index value starting at 0, which can be negative, representing access from back to front:
>>> vehicle = ['train','bus','car','ship'] >>> vehicle[-2] 'car'
Parentheses {}
The curly braces {} in Python:
Represents the dict dictionary datatype, which is the only built-in mapping type in Python. The values in a dictionary are in no particular order, but are stored under a specific key. The key can be a number, a string with a meta ancestor.
typical example
>>> dic = {'jay':'boy','may"':'girl'} >>> dic {'jay': 'boy', 'may': 'girl'}
The list() function allows you to convert a dictionary into a list, but a list cannot be converted into a dictionary.
Similarly, a dictionary can be converted to a tuple through the tuple() function, but a tuple cannot be converted to a dictionary
To this point this article on Python3 parentheses (), parentheses [], brackets {} the difference between the article is introduced to this, more related Python3 parentheses content, please search for my previous articles or continue to browse the following related articles I hope you will support me in the future more!