cars = ["bmw", "audi", "toyota", "subaru"]
cars.sort()
print(cars)

输出为:

['audi', 'bmw', 'subaru', 'toyota']

反向排序:

cars = ["bmw", "audi", "toyota", "subaru"]
cars.sort(reverse = True) print(cars)

输出为:

['toyota', 'subaru', 'bmw', 'audi']

Python自学:第三章 使用方法sort( )对列表进行永久性排序的更多相关文章

  1. Python自学:第三章 使用函数sort( )对列表进行临时排序

    # -*- coding: GBK -*- cars = ["bmw", "audi", "toyota", "subaru&qu ...

  2. Python自学:第三章 使用方法pop()删除元素

    motorcycle = ["honda", "yamaha", "suzuki"] last_owned = motorcycle.pop ...

  3. Python自学:第三章 确定列表长度

    >>> cars = ["bmw", "audi", "toyota", "subaru"] > ...

  4. Python自学:第三章 倒着打印列表

    # -*- coding: GBK -*- #reverse: 相反的 cars = ["bmw", "audi", "toyota", & ...

  5. Python自学:第三章 动手试一试 3-4、3-5

    # -*- coding: GBK -*- liebiao = ["zhang", "li", "wang", "zhou&quo ...

  6. Python自学:第三章 根据值删除元素

    motorcycles = ["honda", "yamaha", "suzuki", "ducati"] print( ...

  7. Python自学:第三章 弹出列表中任何位置处的元素

    motorcycles = ["honda", "yamaha", "suzuki"] first_owned = motorcycles. ...

  8. Python自学:第三章 使用del语句删除元素

    motorcycles = ["honda", "yamaha", "suzuki"] print(motorcycles) del mot ...

  9. Python自学:第三章 在列表末尾添加元素与在列表中插入元素

    motorcycles = ['honda', 'yamaha' ,'suzuki'] motorcycles.insert(0, "ducati") print(motorcyc ...

随机推荐

  1. Vue2.0 入门 安装Vue-cli

    因为要用到npm命令先按装node.js 具体安装如下: 一.安装Node.js步骤 1.下载对应你系统的Node.js版本:https://nodejs.org/en/download/2.选安装目 ...

  2. C#调用java方法踩坑记

    首先,我的java代码写了一个遗传算法,这是我硕士毕业论文的核心算法,项目是基于C#的web项目.但是现在又不想用C#重写遗传算法代码,于是就想用C#去调用java的代码.在网上找了方法,一般有两种: ...

  3. sitecore8.2 如何关闭性能计数器

    在Sitecore.config文件或补丁文件修改Counters.Enabled为false值,此key默认为true;然后再修改Sitecore.Tasks.CounterDumpAgent 时间 ...

  4. Windbg程序调试系列4-Live Debugging

    上篇博文中给大家分享了使用Windbg分析线程阻塞问题: Windbg程序调试系列3-线程阻塞问题 本篇中我们继续,跟大家分享附加进程实时调试-Live Debugging. 先说一下使用Windbg ...

  5. css中height 100vh的应用场景,动态高度百分比布局,浏览器视区大小单位

    css中height 100vh的应用场景,动态高度百分比布局,浏览器视区大小单位 height:100vh 一些只能vw, vh才能完成的应用场景: 1. 场景之:元素的尺寸限制 vw vh 主要是 ...

  6. linux单项目发布流程

    1.安装python #1.安装python3.7所需要的依赖包yum -y groupinstall "Development tools"yum -y install zlib ...

  7. webServices接口开发过程中项目启动遇到的错误org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 422; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-bean

    org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 422; schema_reference.4: Failed to read ...

  8. 利用python把成绩用雷达图表示出来

    第一步:知道自己的成绩. 第二步:插入代码. import numpy as np import matplotlib.pyplot as plt import matplotlib matplotl ...

  9. 【js】了解前端缓存,收获不止于此!

    了解前端缓存,收获不止于此! 这次我们来讲一下关于前端缓存的问题.感谢赵欢同学提供doc素材. 首先,开局我画了一张图,你会对文章有一个大局了解. 今天讲的是前端缓存. 前端缓存有3大种:如图,分为H ...

  10. 16: mint-ui移动端

    1.1 mint-ui安装与介绍  官网:http://mint-ui.github.io/docs/#/zh-cn2/loadmore 1.安装与引用 // 安装Vue 2.0 npm instal ...