python_变量类型

列表:用[]标识,可以用下标进行访问,可以更改值

List = [123,’book’]

print List

元组:用()标识,可以用下标进行访问,但是不能更改元素值,相当于只读

tuple = (123,’book’)

print tuple * 2 #输出两次

字典:用{}来标识,字典又索引和值组成

dict = {}
dict[‘one’] = “this one”
dict[2] = “this two”
dict[3] = 3
Dict2 = {1:’one’,2:’two’}

print dict
Print dict[‘one’]
Print dict.keys()
Print dict.values()

猜你喜欢

转载自www.cnblogs.com/penuel/p/12006405.html