python3 base 2

# List (list, array), tuples, dictionaries

list_ = ["a", "c", 1, 2]

print(list_)

# List_.append ( "c") # append
# list_ [2] = "cc " # replace / modify
# list_.insert (1, "b" ) # Insert
list_.remove ( "c") # Delete

print(list_)

print ( "=============================== tuple ===")

tuple_ = ("a", "b", "c", 1, 2)

print (tuple_ [0: -2]) # fetch range

# Del tuple_ # delete the entire tuple

print(tuple_[0])


print ( "=============================== Dictionary ===")

dict_ = {"key":"value", "name":"tom", "age": 29}

for k, v in dict_.items():
print(k)
print(v)

print (dict_.keys ()) # accessible to all Key
Print (dict_.values ()) to get all of the value #

# Dict _ [ "hello"] = "world" # Add
# dict _ [ "key"] = "vvvv" # replacement / modification

del dict_["key"]

print(dict_)

ll = [
["a", "b", "c"],
[1, 2, 3],
]

print(ll[1][2])

ld = [
{"name": ("tom", "jack"),
{"age": 29},
]

dl = {"name":["tom", "jack", "blue"],
"age": [22, 27, 31]}

print(ld[1]["age"])
print(dl["name"][1])

 

Guess you like

Origin www.cnblogs.com/hy546880109/p/12041860.html