# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之函数用法startswith()
#http://www.runoob.com/python/att-string-startswith.html #startswith()
#说明:返回布尔值,用于检查字符串是否是以指定子字符串开头,如果是则返回 True,否则返回 False。
'''
startswith(...)
S.startswith(prefix[, start[, end]]) -> bool
prefix:前缀
start:字符串的开始位置
end:字符串结束位置 Return True if S starts with the specified prefix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
prefix can also be a tuple of strings to try.
''' #案例
#判断字符串是否以指定字符串开头
str='xiaodeng love python'
prefix='xiaodeng'
print str.startswith(prefix)#True
prefix='deng'
print str.startswith(prefix,4)#True
prefix='love'
print str.startswith(prefix,4,13)#True

python之函数用法startswith()的更多相关文章

  1. Python回调函数用法实例详解

    本文实例讲述了Python回调函数用法.分享给大家供大家参考.具体分析如下: 一.百度百科上对回调函数的解释: 回调函数就是一个通过函数指针调用的函数.如果你把函数的指针(地址)作为参数传递给另一个函 ...

  2. python之函数用法setdefault()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法setdefault() #D.get(k,d) #说明:k在D中,则返回 D[K], ...

  3. python之函数用法fromkeys()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法fromkeys() #fromkeys() #说明:用于创建一个新字典,以序列seq ...

  4. python之函数用法get()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法get() #http://www.runoob.com/python/att-dic ...

  5. python之函数用法capitalize()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法capitalize() #capitalize() #说明:将字符串的第一个字母变成 ...

  6. python之函数用法isupper()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法isupper() #http://www.runoob.com/python/att ...

  7. python之函数用法islower()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法islower() #http://www.runoob.com/python/att ...

  8. python之函数用法endswith()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法endswith() #http://www.runoob.com/python/at ...

  9. python之函数用法xrange()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法xrange() #xrange() #说明:返回一个生成器 #xrange做循环的性 ...

随机推荐

  1. hdu 1038 Biker's Trip Odometer(水题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=1038 Biker's Trip Odometer Time Limit: 2000/1000 MS ...

  2. go语言之进阶篇数组越界导致panic

    1.数组越界导致panic 示例: package main import "fmt" func testa() { fmt.Println("aaaaaaaaaaaaa ...

  3. EF和LINQ 调用存储过程

    好久没有更新文章了,最近项目比较忙都没什么时间来分享最近的问题. 今天遇到一个超级傻逼的问题.C#中调用存储过程,自己code也10来年了,这应该是很简单的问题了.今天有2个新的api,一个只有1个参 ...

  4. sharepoint 2010 自定义页面布局

    在sharepoint开发中经常遇到 自定义网站栏.内容类型,页面布局和模板页也会遇到,遇到机会就相对比较小. 首先新建一个空的sharepoint项目: 1)创建网站兰: 修改SiteColumns ...

  5. MSSQL 数据库语句原来是区分大小写的啊

    一直以来我们都认为数据库语句是不区分大小写,其实这是错误的认识,之所以不区分是因为数据库语言不区分大小写.这里我们以mssql2005中自带的AdventureWorksDW数据库为例. 执行以下语句 ...

  6. ThinkPHP3.2.3使用分页

    首先要搞清楚的就是ThinkPHP3.2.3的分页类已经被移到了Think\Page.class.php,这是跟以前的版本有些不一样的,使用起来还是跟以前版本差不多,但是默认的效果不敢恭维,所以最好是 ...

  7. Set Matrix Zeroes leetcode java

    题目: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. cl ...

  8. \r\n 如何转换成utf-8格式的,在jsp页面中正常显示换行

    数据库中存的换行是\r\n,读取到UTF-8编码的JSP 页面上以后,没有换行 在jsp页面显示之前,要进行一下字符转换,将所有\r\n转换成<br>,如下: String result  ...

  9. a,b盘去哪儿?

    我们知道,电脑的硬盘从c盘开始了,那我们不仅要问了,a,b盘符去哪儿了? 打开Windows系统的电脑,看到的第一个硬盘分区是C盘,请问A盘和B盘在哪里?所谓的硬盘分区号就是盘符,也就是驱动器号,是微 ...

  10. 建模角度理解word embedding及tensorflow实现

    http://www.jianshu.com/p/d44ce1e3ec2f 1. 前言 本篇主要介绍关键词的向量表示,也就是大家熟悉的word embedding.自Google 2013 年开源wo ...