博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python之函数用法startswith()
阅读量:6995 次
发布时间:2019-06-27

本文共 737 字,大约阅读时间需要 2 分钟。

# -*- 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)#Trueprefix='deng'print str.startswith(prefix,4)#Trueprefix='love'print str.startswith(prefix,4,13)#True

 

转载地址:http://rrivl.baihongyu.com/

你可能感兴趣的文章
Codeforces #263 div2 解题报告
查看>>
python 面向对象编程
查看>>
【转】Python3 操作符重载方法
查看>>
linux 服务器名 访问 shh免密码登录
查看>>
java装箱拆箱
查看>>
C#综合揭秘——通过修改注册表建立Windows自定义协议
查看>>
adf 笔记
查看>>
linux 除了某个文件或某个文件夹以外全部删除
查看>>
下面就介绍下Android NDK的入门学习过程(转)
查看>>
(转)Unity3D占用内存太大的解决方法
查看>>
[MEAN+ Webstrom] First API -- 2.Debug Node.js RESTful application
查看>>
实现能够直接粘QQ贴截图的bug管理功能
查看>>
vsftpd允许root用户登录
查看>>
【DFS】NYOJ-325-zb的生日
查看>>
【翻译】ES6生成器简介
查看>>
POJ 3928 & HDU 2492 Ping pong(树阵评价倒数)
查看>>
ORACLE工作原理小结
查看>>
android点滴之PendingIntent的使用
查看>>
2015 年 JavaScript 开发者调查报告
查看>>
class、interface、struct的差别
查看>>