元素的序列数据都可以进行数据拆解,如下
#元组 data_tuple = (1,2,3) a,b,c = data_tuple print(a) #列表 data_list = [11, 22, 33] a2, b2, c2 = data_list print(a2) #字典 data_dic = {'name':'zhangsan', 'age':'20'} print(data_dic["name"]) #获取字典的键值 a3, b3 = data_dic.items() print(a3) #字符串 data_str = 'abcde' a4, b4, c4, d4, e4 = data_str print(a4)
打印结果:
1
11
zhangsan
('name', 'zhangsan')
a