• Python的取值


    list1 =[1, 2, 3, 4, 5, 6]
    list2 =['a', 'b', 'c', 'd', 'e', ]
    list3 =[1, 3, 'a', 'c', True]
    print(list1)
    print('使用切片方式获取指定list1第三个元素:%d' % list1[3])
    print('获取最后一个元素:%d' % list1[-1])
    print('获取第一个元素:%s' % list1[:1])
    print('获取第2到3的元素:%s' % list1[1:3])
    print('获取倒数第三道1:%s' % list1[3:1])
    list1.append(2)
    # 用1,2,3,4分别组成三位数
    num = 0
    for a in range(1, 5):
    for b in range(1, 5):
    for c in range(1, 5):
    if a == b or a == c or c == b:
    continue
    print("{}{}{}".format(a, b, c))
    num += 1

    s = ['nihao', 'woshi', '???']
    s.append('pi')
    print(s)
    s = ['nihao', 'woshi', '???']
    s.insert(2, 'nidaye')
    print(s)
    s = ['nihao', 'woshi', '???']
    s.extend('wodelaojiaaaa')
    print(s)
    s = ['nihao', 'woshi', '???']
    s.pop(0)
    print(s)
    s = ['nihao', 'woshi', '???']
    s.remove('woshi')
    print(s)
    s = ['nihao', 'woshi', '???']
    s.clear()
    print(s)
    s = ['nihao', 'woshi', '???']
    del[s]
    s = ['nihao', 'woshi', '???']
    del s[0:2]
    print(s)
    s = ['nihao', 'woshi', '???']
    s[1] = 'nihao'
    print(s)
    li = [1, 2, 3, 4, 5, 'money', 2, 2, 3, 4, 5, 'nihaoa']
    li[1] = 'aaaa'
    print(li)
    li = [1, 2, 3, 4, 5, 'money', 2, 2, 3, 4, 5, 'nihaoa']
    li[0:2] = 'a'
    print(li)
    names = ['de', 'ma', 'xi', 'ya']
    print(names[2])
    names = ['mike', 'mark', 'candice', 'laular']
    print(names[1:3])
    print(names[2:])
    print(names[:3])
    print(names[:])
    print(names[-1])
    print(names[1:3])
  • 相关阅读:
    Redis主从复制、哨兵Sentinel、集群简单介绍
    Redis集群
    Redis哨兵模式
    Redis主从架构
    Redis持久化方式
    缓存2.2——Redis并发竞争
    DOM内容梳理2
    纯js制作九宫格
    正则表达式内容梳理
    JavaScript之DOM详解
  • 原文地址:https://www.cnblogs.com/zxpnb/p/14275420.html
Copyright © 2020-2023  润新知