zoukankan      html  css  js  c++  java
  • Python列表的常用操作

    '''#代码开始
    list_1=['gong','juanxu','jing']
    print(list_1[2])
    list_1[2]="xia" #添加一个元素
    print(list_1)
    print("Wellcome to there ",list_1[0])
    print("Wellcome to there ",list_1[1])
    print("Wellcome to there ",list_1[2])
    for i in ("chen","Ronin","Jimi"): 遍历插入元素
    list_1.append(i)
    print(list_1)
    list_1.insert(0,"chun") #在选择的位置插入元素
    list_1.insert(3,"chun")
    list_1.append("qing")
    print(list_1)
    for i in list_1:
    print("Wellcome to there ",i)

    num_bg=0
    while True:
    num_bg +=1
    if num_bg == 8:
    break
    else:
    guest=list_1.pop()
    print("I'am Sorry ",guest.title())
    print(list_1)
    print("Hello ",list_1[0],list_1[1])
    del list_1[0,1]
    print(list_1)
    '''代码结束

    list_2=["chongqing","hubei","guagxi","beihai"]
    '''
    print(sorted(list_2,reverse=True))
    print(list_2)
    '''
    list_2.reverse()#反转列表
    print(list_2)
    list_2.reverse()
    print(list_2)
    list_2.sort()#排序
    print(list_2)
    list_2.sort()
    print(list_2)
  • 相关阅读:
    MongoDB的安装与简单使用
    [SCOI2008]天平
    [ZJOI2008]树的统计
    [HEOI2015]兔子与樱花
    [HAOI2006]l旅行
    [ZJOI2008]泡泡堂BNB
    [ZJOI2007]时态同步
    [SCOI2005]栅栏
    [SCOI2008]着色方案
    [SCOI2005]互不侵犯King
  • 原文地址:https://www.cnblogs.com/gshelldon/p/10403505.html
Copyright © 2011-2022 走看看