_ 12. A second container Dictionary

# ### two containers: the outer container is a type of data, or the elements inside a container type data 
listvar = [1,2,3, (4,5,6) ] # secondary containment 
 
# two lists 
listvar = [l, 2,3, [4,5,6]] 
Print (listvar) 
 
# two tuple 
TUP = (3,5, (7,8,9)) 
Print (TUP) 
 
# set of two (only can be stored tuple) 
setvar = {l, 2,3, (11,22,33)} 
Print (setvar) 
 
# two dictionaries 
dictvar = { 'a': { 'c': 333}, 'b': 2 } 
# remove 333 
Print (dictvar [ 'A'] [ 'C']) 
 
# four containers 
container = [1,2,3, (4,5,6, { "a": 1, "b": [ 7,8,9]}), 90] 
# removed. 9 
RES = container [-2] [- 1] [ "B"] [- 1] 
Print (RES) 
 
# of equal length two containers   
' '' 
(1 ) which each element type data container 
(2) the number of elements of each type of data container are identical 
'' '
container = [(1,2,3),[4,5,6]]
 
  
# ### dictionary casts
''' 
Required as long as the two containers, and each container inside the two elements can only be 
' '' 
 
# (1) is outside the list, which is a list or tuple or string 
listvar = [[ "a" , 1], ( "b" , 2), "c123"] # string caution if the value is more, there are limitations 
listvar = [[ "a", 1], ( "b", 2)] # recommended *** 
RES = dict (listvar) 
Print (RES) 
 
# (2) is outside a tuple, which is a list of tuples or string 
tuplevar = ([ "c", 11], ( "d", 23)) # recommended *** 
RES = dict (tuplevar) 
Print (RES) 
 
# exception: If the list or tuple container to put the set, is not being given the grammar, but the situation unexpectedly, reach the desired effect 
container = dict ([ { "a", 1}, { "b", 2}]) # deprecated 
Print (Container) 
 
# (. 3) are set out, there is a tuple or string 
setvar = {( 'a', 1) , ( 'b', 2) , "c3"} # immutable data must be placed, to hash 
RES = dict (setvar) 
Print (RES) 
 
 
"""
int() float() bool() complex()
str() list() tuple() set() dict()
When performing these functions strong turn, are converted into the current default data type  
in this manner can also initialize a variable 
"" "
RES = int () 
RES = List () 
Print (RES)

  

Guess you like

Origin www.cnblogs.com/eliwen/p/10967689.html