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的更多相关文章

  1. Python 字符串操作及string模块使用

    python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求: python的字符串属性函数 python的string模块 1.字符串属性方法操作: 1.>字符串格式输出对 ...

  2. python中string模块各属性以及函数的用法

    任何语言都离不开字符,那就会涉及对字符的操作,尤其是脚本语言更是频繁,不管是生产环境还是面试考验都要面对字符串的操作.     python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串 ...

  3. 牛人总结python中string模块各属性以及函数的用法,果断转了,好东西

    http://blog.chinaunix.net/uid-25992400-id-3283846.html http://blog.csdn.net/xiaoxiaoniaoer1/article/ ...

  4. python字符串(string)方法整理

    python中字符串对象提供了很多方法来操作字符串,功能相当丰富. print(dir(str)) [..........'capitalize', 'casefold', 'center', 'co ...

  5. string method and regular expresions

    <!doctype html> <!DOCTYPE html> <html> <head> <meta charset="utf-8&q ...

  6. Python String 方法详解

    官网文档地址:https://docs.python.org/3/library/stdtypes.html#string-methods 官网 公号:软测小生ruancexiaosheng 文档里的 ...

  7. python 之 string() 模块

    common string oprationsimport string1. string constants(常量) 1) string.ascii_letters       The concat ...

  8. Java笔记之java.lang.String#trim

    String的trim()方法是使用频率频率很高的一个方法,直到不久前我不确定trim去除两端的空白符时对换行符是怎么处理的点进去看了下源码的实现,才发现String#trim的实现跟我想像的完全不一 ...

  9. 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 ...

随机推荐

  1. poj 3259 bellman最短路推断有无负权回路

    Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 36717   Accepted: 13438 Descr ...

  2. 【iOS】UICollectionView自己定义Layout之蜂窝布局

    网上的UICollectionView的Layout布局,其cell的形状多为矩形和圆形. 本篇博文将正六边形作为cell的基本形状,为您展现独特的蜂窝布局效果及实现源代码. 帮助您让自己的App脱颖 ...

  3. 基于redis ae实现 Linux中的文件系统监控机制(inotify)

    (英文部分为转的.代码是个人代码) 1 What's inotify  The inotify API provides a mechanism for monitoring file system ...

  4. C++继承中析构函数 构造函数的调用顺序以及虚析构函数

    首先说说构造函数.大家都知道构造函数里就能够调用成员变量,而继承中子类是把基类的成员变成自己的成员,那么也就是说子类在构造函数里就能够调用基类的成员了,这就说明创建子类的时候必须先调用基类的构造函数, ...

  5. Revit二次开发实现BIM盈利(以橄榄山快模为例解说) 视频讲座下载

    应笔墨闲谈群的邀请, 在10月11号晚8:30分在其群做了一次关于BIM二次开发的讲座. 因为參与者基本上都是从设计院和施工单位来的,所以对Revit二次开发做了纵览性的解说, 以非程序猿能听懂的方式 ...

  6. Windows身份验证和混合验证的差别

    两个验证方式的不同主要集中在信任连接和非信任连接.         windows 身份验证相对于混合模式更加安全,使用本连接模式时候,sql不推断sapassword.而仅依据用户的windows权 ...

  7. FireFox所支持的全部标签(持续更新ing)

    近期研究上各个浏览器的差别,得到一些资料,FireFox眼下所支持的全部标签类型,持续更新,供大家參考和学习,不喜勿喷哦 http://mxr.mozilla.org/seamonkey/source ...

  8. 不仅仅是Google,您必须知道的全球十大地图API

    不仅仅是Google,您必须知道的全球十大地图API 一.总结 一句话总结:除了google,也有其它很多很好的地图,必应地图(Bing Maps),OpenLayers 二.不仅仅是Google,您 ...

  9. cximage功能简介

    CxImage是一个可以用于MFC 的C++图像处理类库类,它可以打开,保存,显示,转换各种常见格式的图像文件,比如BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, ...

  10. Android VelocityTracker类和Scroller类

    VelocityTracker类:用于跟踪触屏事件的速度,通常使用VelocityTracker的步骤如下: static VelocityTracker obtain():获取一个VelocityT ...