• 把一个列表分成10组,每组10元素输出一次,奇偶组换色输出


    # coding: UTF-8
    
    import time
    import os,sys
    import  random
    n = 0
    ss = list(range(0,100))
    print (ss)
    for i in ss:
        n += 1
        if n % 2 == 0 :
    #if n % 10 ==0 :
    #print ("33[32m下一轮") print ('33[34m%s' %n) else: print('33[37m%s' % n) print ("------------------------------- ") jj = 0 for ii in range(0,100,10): #一个100个元素的列表 tt = ss[ii:ii + 10] #把列表拆分为10组,每组10个元素
    jj
    += 1 #计数 加 1 print (tt) for pp in tt: if jj % 2 == 0: print ("33[32m%d" %pp) else: print ("33[37m%d" %pp)

    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    -------------------------------

    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
    [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
    [30, 31, 32, 33, 34, 35, 36, 37, 38, 39]
    [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
    [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
    [60, 61, 62, 63, 64, 65, 66, 67, 68, 69]
    [70, 71, 72, 73, 74, 75, 76, 77, 78, 79]
    [80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
    [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]

    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    [30, 31, 32, 33, 34, 35, 36, 37, 38, 39]
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    [60, 61, 62, 63, 64, 65, 66, 67, 68, 69]
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    [70, 71, 72, 73, 74, 75, 76, 77, 78, 79]
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    [80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99

    # coding: UTF-8
    
    import time
    import os,sys
    import  random
    ss = list(range(0,100))
    jj = 0
    
    for ii in range(0,100,10):
    
        tt = ss[ii:ii + 10]
    
    
        if jj % 2 == 0:              #第一次输出
           print("33[32m%s"%tt)
           for pp in tt:
               print("33[32m%d" % pp)
        else:
            print("33[37m%s" % tt)
            for pp in tt:
                print("33[37m%d" % pp)
        jj += 1

  • 相关阅读:
    cocos2d-x CCNotificationCenter一个优化想法
    【备忘】尾调用(尾递归)--来自维基百科
    [转] 关于Mongodb的全面总结,学习mongodb的人,可以从这里开始
    [转]编程修养
    DirectX11 SDK 例程报错解决方法
    unity3d Vector3.Lerp解析
    unity3d 三分钟实现简单的赛车漂移
    Unity 5.3.1 No Android/IOS module loaded
    unity3d 音频无缝循环
    unity3d 扩展NGUI Tweener —— TweenTime
  • 原文地址:https://www.cnblogs.com/chengxuyonghu/p/14768398.html
Copyright © 2020-2023  润新知