Python笔记 #04# Methods
源:DataCamp
datacamp 的 DAILY PRACTICE + 日常收集。
缺一
Methods
You can think of methods as functions that "belong to" Python objects.


String Methods
# string to experiment with: room
room = "poolhouse" # Use upper() on room: room_up
room_up = room.upper() # Print out room and rosom_up
print(room)
print(room_up) # Print out the number of o's in room
print(room.count('o'))
poolhouse
POOLHOUSE
3
List Methods
# Create list areas
areas = [11.25, 18.0, 20.0, 10.75, 9.50] # Print out the index of the element 20.0
print(areas.index(20.0)) # Print out how often 14.5 appears in areas
print(areas.count(14.5))
# Create list areas
areas = [11.25, 18.0, 20.0, 10.75, 9.50] # Use append twice to add poolhouse and garage size
areas.append(24.5)
areas.append(15.45) # Print out areas
print(areas) # Reverse the orders of the elements in areas
areas.reverse() # Print out areas
print(areas)
Python笔记 #04# Methods的更多相关文章
- 我的Python笔记04
摘要: 声明:本文整理借鉴金角大王的Python之路,Day4 - Python基础4 (new版) 本节内容 迭代器&生成器 装饰器 Json & pickle 数据序列化 软件 ...
- python笔记04:字典
4.1 字典的使用 字典:通过名字来引用值的数据结构,又称为映射 字典中的值并没有特殊的顺序,但是都存储在一个特定的键下 字典提供的功能:快速查找特定键值对应关系 某些情况下,字典比列表更好用一些 ...
- python笔记04
数据类型(二) 今日内容 1.列表 2.元组 内容回顾和补充 1.计算机基础 ①硬件:cpu,内存,硬盘,主板,网卡 ②操作系统:linux,centos, Ubuntu,redhat windows ...
- MIT 计算机科学及编程导论 Python 笔记 1
计算机科学及编程导论在 MIT 的课程编号是 6.00.1,是计算机科学及工程学院的经典课程.之前,课程一直使用 Scheme 作为教学语言,不过由于 Python 简单.易学等原因,近年来已经改用 ...
- python笔记-1(import导入、time/datetime/random/os/sys模块)
python笔记-6(import导入.time/datetime/random/os/sys模块) 一.了解模块导入的基本知识 此部分此处不展开细说import导入,仅写几个点目前的认知即可.其 ...
- 机器学习实战(Machine Learning in Action)学习笔记————04.朴素贝叶斯分类(bayes)
机器学习实战(Machine Learning in Action)学习笔记————04.朴素贝叶斯分类(bayes) 关键字:朴素贝叶斯.python.源码解析作者:米仓山下时间:2018-10-2 ...
- Python学习--04条件控制与循环结构
Python学习--04条件控制与循环结构 条件控制 在Python程序中,用if语句实现条件控制. 语法格式: if <条件判断1>: <执行1> elif <条件判断 ...
- Python笔记之不可不练
如果您已经有了一定的Python编程基础,那么本文就是为您的编程能力锦上添花,如果您刚刚开始对Python有一点点兴趣,不怕,Python的重点基础知识已经总结在博文<Python笔记之不可不知 ...
- boost.python笔记
boost.python笔记 标签: boost.python,python, C++ 简介 Boost.python是什么? 它是boost库的一部分,随boost一起安装,用来实现C++和Pyth ...
随机推荐
- linux上如何快速删除一个目录
在linux中删除一个目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中,现在使用rm -rf命令即可解决.直接rm就可以了,不过要加两个参数-rf 即:rm -rf ...
- UIGestureRecognizer学习笔记
一.Gesture Recognizers Gesture Recognizers是在iOS3.2引入的,可以用来识别手势.简化定制视图事件处理的对象.Gesture Recognizers的基类为U ...
- spring aop 样例
基于注解的AOP 方式 1.加入jar包 com.springsource.org.aopalliance-1.0.0.jar com.springsource.org.aspectj.weaver- ...
- jquery类似方法的比较(二)
(1)append()&appendTo()&prepend()$prependTo() (2)after()&before()&insertAfter()&i ...
- java中生成流水号的一个例子(使用BerkeleyDB)
package com.jiaoyiping.berkeleydb; import com.sleepycat.je.*; import com.sleepycat.utilint.StringUti ...
- AB压力测试工具
1.安装AB工具: yum install httpd-tools 2.测试: ab -n -c http://localhost.com/ 其中-n表示请求数,-c表示并发数 3.测试结果 [roo ...
- 最大网络流(Dinic)
hdu1532 Drainage Ditches Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- [Gradle] 输出构建 APK 的版本名到文件
android { // 输出版本名到 build 目录下的 version_name.txt 文件 applicationVariants.all { variant -> project.t ...
- nginx解决带_的head内容丢失
若请求 Head 信息中存在自定义信息并且以 "_" 下划线间隔,则必须配置underscores_in_headers 否则 Head 无法向 Tomcat 转发 解决办法: 在 ...
- Introduction to Structured Data json的2种形式 JAVA解析JSON数据 - JsonArray JsonObject
https://developers.google.com/search/docs/guides/intro-structured-data Structured data refers to kin ...