Python自学之collection

来源:互联网 发布:iphone7plus在线软件 编辑:程序博客网 时间:2024/05/01 10:23
# 定义数组x = [31.8, 33.9, 35.0, 33.9, 33.8, 33.0, 33.0, 34.4, 36.5, 38.0, 39.3, 40.7, 41.7, 41.4, 40.7, 39.9]# 数组遍历for a in x:     print (a) # 数组遍历for i in range(0, len(x)):     print (i, x[i]) #mapinformation=['liusen',25]print(information[1]+1)#负数表示从另一边查找print(x[-1])print(x[3:-3])print(x[3:-3:2])x=[1,2,3]y=[4,5,6]print(x+y)s=[1]*12print(s)print(len(s))m='python'*5print(m)

实验结果:

31.833.935.033.933.833.033.034.436.538.039.340.741.741.440.739.90 31.81 33.92 35.03 33.94 33.85 33.06 33.07 34.48 36.59 38.010 39.311 40.712 41.713 41.414 40.715 39.92639.9[33.9, 33.8, 33.0, 33.0, 34.4, 36.5, 38.0, 39.3, 40.7, 41.7][33.9, 33.0, 34.4, 38.0, 40.7][1, 2, 3, 4, 5, 6][1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]12pythonpythonpythonpythonpython
0 0
原创粉丝点击