Python自学:第三章 根据值删除元素
motorcycles = ["honda", "yamaha", "suzuki", "ducati"]
print(motorcycles) motorcycles.remove("ducati")
print(motorcycles)
输出为:
['honda', 'yamaha', 'suzuki', 'ducati']
['honda', 'yamaha', 'suzuki']
2、
motorcycles = ["honda", "yamaha", "suzuki", "ducati"]
print(motorcycles) too_expensive = "ducati"
motorcycles.remove(too_expensive)
print(motorcycles)
print("\nA " + too_expensive.title() + " is too expenfive for me.")
输出为:
['honda', 'yamaha', 'suzuki', 'ducati']
['honda', 'yamaha', 'suzuki'] A Ducati is too expenfive for me.
Python自学:第三章 根据值删除元素的更多相关文章
- Python自学:第三章 使用方法pop()删除元素
motorcycle = ["honda", "yamaha", "suzuki"] last_owned = motorcycle.pop ...
- Python自学:第三章 使用del语句删除元素
motorcycles = ["honda", "yamaha", "suzuki"] print(motorcycles) del mot ...
- Python自学:第三章 使用列表中的各个值
bicycles = ['trek','cannondale','redline','specialized'] message = "My first bicycle was a &quo ...
- Python自学:第三章 确定列表长度
>>> cars = ["bmw", "audi", "toyota", "subaru"] > ...
- Python自学:第三章 倒着打印列表
# -*- coding: GBK -*- #reverse: 相反的 cars = ["bmw", "audi", "toyota", & ...
- Python自学:第三章 使用函数sort( )对列表进行临时排序
# -*- coding: GBK -*- cars = ["bmw", "audi", "toyota", "subaru&qu ...
- Python自学:第三章 使用方法sort( )对列表进行永久性排序
cars = ["bmw", "audi", "toyota", "subaru"] cars.sort() print ...
- Python自学:第三章 动手试一试 3-4、3-5
# -*- coding: GBK -*- liebiao = ["zhang", "li", "wang", "zhou&quo ...
- Python自学:第三章 弹出列表中任何位置处的元素
motorcycles = ["honda", "yamaha", "suzuki"] first_owned = motorcycles. ...
随机推荐
- Your password does not satisfy the current policy requirements问题解决方法
运行 mysql>set validate_password_policy=0; 目的是,可以设置弱密码.
- 将文件转成clob添加到Oracle数据库中
Controller层: @Controller@RequestMapping(value = {"/Test/TestController"})public class Test ...
- supervisor配置详解(转)
有阵子没写博客了,这段时间一直在研究python django框架和前端相关的东西.楼主学通信的,对web这一块啥也不懂,学了一个礼拜django,接着学了2个礼拜前端,感觉还是做不出来一个好看的页面 ...
- openwrt路由器进入安全模式
openwrt路由器型号:WNDR3800 一.实验背景 在pc机上通过xshell软件登录openwrt路由器,pc机通过网线与openwrt路由器的LAN接口相连.openwrt路由器自带两块无线 ...
- Azure上搭建ActiveMQ集群-基于ZooKeeper配置ActiveMQ高可用性集群
ActiveMQ从5.9.0版本开始,集群实现方式取消了传统的Master-Slave方式,增加了基于ZooKeeper+LevelDB的实现方式. 本文主要介绍了在Windows环境下配置基于Zoo ...
- Machine Learning 第三周
ML week3 逻辑回归 Logistic Function h_\theta(x)=g(\theta^Tx) g(t)=\frac{1}{1+e^{-z}} 当t大于0, 即下面公式成立时,y=1 ...
- ubuntu+anaconda+mxnet环境配置
为了insightface和mxnet较劲的一天 mxnet环境: 官网下载pyhton2.7版本的anaconda,随便找个安装教程 sh Anacondaxxxx.sh #一路默认即可,第二个回车 ...
- pandas的基本功能(一)
第16天pandas的基本功能(一) 灵活的二进制操作 体现在2个方面 支持一维和二维之间的广播 支持缺失值数据处理 四则运算支持广播 +add - sub *mul /div divmod()分区和 ...
- vmware中centos6.7系统图形化安装Oracle显示乱码问题解决
root下: 修改环境属性 vi /etc/sysconfig/i18n LANG="en_US.UTF-8 1.在每次调用图形界面以前,我们使用export临时设置LANG(ORACLE ...
- Python爬虫与一汽项目【综述】
项目来源 这个爬虫项目是 去年实验室去一汽后的第一个项目(基本交工,现在处于更新维护阶段).内容大概是,获取到全国31个省份政府的关于汽车的招标公告,再用图形界面的方式展示爬虫内容.在完成政府招标采购 ...