String methods
A method is similar to a function – it takes arguments and returns a value – but the syntax is different. For example, the method upper takes a string and return a new string with all uppercase letters. Instead of the function syntax upper(text), it uses the method syntax text.upper().

This form of dot notation specifies the name of the method, upper, and the name of the string to apply the method to, text. The parentheses indicate that this method has no parameters.
A method call is called an invocation; in this case, we would say that we are invoking upper on the word.

As it turns out, there is a string method named find that is remarkably similar to the function we wrote. Actually, the find method is more general than our function: it can find substrings, not just characters:

It can take as a second argument the index where it should, and the third argument the index where it should end:

from Thinking in Python
String methods的更多相关文章
- Python 字符串操作及string模块使用
python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求: python的字符串属性函数 python的string模块 1.字符串属性方法操作: 1.>字符串格式输出对 ...
- python中string模块各属性以及函数的用法
任何语言都离不开字符,那就会涉及对字符的操作,尤其是脚本语言更是频繁,不管是生产环境还是面试考验都要面对字符串的操作. python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串 ...
- 牛人总结python中string模块各属性以及函数的用法,果断转了,好东西
http://blog.chinaunix.net/uid-25992400-id-3283846.html http://blog.csdn.net/xiaoxiaoniaoer1/article/ ...
- python字符串(string)方法整理
python中字符串对象提供了很多方法来操作字符串,功能相当丰富. print(dir(str)) [..........'capitalize', 'casefold', 'center', 'co ...
- string method and regular expresions
<!doctype html> <!DOCTYPE html> <html> <head> <meta charset="utf-8&q ...
- Python String 方法详解
官网文档地址:https://docs.python.org/3/library/stdtypes.html#string-methods 官网 公号:软测小生ruancexiaosheng 文档里的 ...
- python 之 string() 模块
common string oprationsimport string1. string constants(常量) 1) string.ascii_letters The concat ...
- Java笔记之java.lang.String#trim
String的trim()方法是使用频率频率很高的一个方法,直到不久前我不确定trim去除两端的空白符时对换行符是怎么处理的点进去看了下源码的实现,才发现String#trim的实现跟我想像的完全不一 ...
- Intro to Python for Data Science Learning 4 - Methods
Methods From:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-3-function ...
随机推荐
- 超级简单JS网页倒计时代码
<script type="text/javascript"> // JavaScript Document function ShowTimes(){ var Aft ...
- 数据库之Case When
近期几天的工作本来组长是安排我用mindfocion画几个图,本来以为难点是这个控件的使用,可是开发的时候才发现由于数据量有点多,所以在开发的时候汇总这些信息倒是费了我许多的功夫,最后总结一下就是写了 ...
- java.lang.ClassNotFoundException: org.jaxen.JaxenException
java.lang.ClassNotFoundException: org.jaxen.JaxenException java.lang.ClassNotFoundException: org.jax ...
- 从头认识java-16.4 nio的读与写(ByteBuffer的使用)
这一章节我们来讨论一下nio的读与写. 1.nio的读 package com.ray.ch16; import java.io.IOException; import java.io.RandomA ...
- HDU 3949 XOR(高斯消元搞基)
HDU 3949 XOR pid=3949" target="_blank" style="">题目链接 题意:给定一些数字,问任取几个异或值第 ...
- ES正常停止步骤
1. 停止所有index服务 2. 执行curl -XPUT $url/_cluster/settings?pretty -d '{"transient" : {"clu ...
- python 3.x 学习笔记7 ( 模块 (修))
1.定义:模块:用来从逻辑上组织python代码(变量.函数.类.逻辑:实现一个功能),本质就是.py结尾的python文件包:用来从逻辑上组织模块的,本质就是一个目录(必须带有一个__init__. ...
- SVN Commit报错 svn: E155037: Previous operation has not finished; run 'cleanup' if it was interrupted
svn commit 文件出错 svn: E155037: Commit failed (details follow): svn: E155037: Previous operation has n ...
- JavaScript在不同环境下的全局对象
Node.js 环境下,全局的对象是 global. 浏览器下 window === self 而不是 global,今天才发现的,我惊呆了!
- 51nod1073-约瑟夫环,递归。
N个人坐成一个圆环(编号为1 - N),从第1个人开始报数,数到K的人出列,后面的人重新从1开始报数.问最后剩下的人的编号. 例如:N = 3,K = 2.2号先出列,然后是1号,最后剩下的是3号. ...