1, define the way:
li=[element 1, Element 2,.....]
Li=list () Create an empty list by default
2. Convert an iterative element to a list
Li=list (an iterative element) inside for a for loop each element as a list of elements
A, string conversion to List
Str= "Yang Ruijing" li=list (str) print (LI)
result: [' Yang ', ' Rui ', ' Jing ']
B, Ganso convert to List
tu= ("Yang","Rui","jing") Li=list (tu) print (LI)
C, dictionary conversion to list
Dictionary conversion list has three forms of key value items because the dictionary loop is a loop key by default
(1) Default key conversion list
dict={"K1":"Yang","K2":"Rui","K3":"Jing"}li=list (dict) print (LI) ['K3','K1','K2']
(2) Value conversion list
dict={"K1":"Yang","K2":"Rui","K3":"Jing"}li=list (dict.values ()) print (LI) ['Yang','Rui','Jing']
(3) Items conversion list
dict={"K1":"Yang","K2":"Rui","K3":"Jing"}li=list (Dict.items ()) print (LI) [('K1','Yang'), ('K3','Jing'), ('K2','Rui')]
Python--list