小白教程
所有教程
关于
Search
172.70.126.64
172.70.126.64
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 string startswith”的源代码
本页内容
上一节:
Python3_string_splitlines
下一节:
Python3_string_strip
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:startswith(substr, beg=0,end=len(string))}}[[Category:python3 string|33]] = Python3 startswith()方法 = [[python3 string|Python3 字符串]] == 描述 == startswith() 方法用于检查字符串是否是以指定子字符串开头,如果是则返回 True,否则返回 False。如果参数 beg 和 end 指定值,则在指定范围内检查。 == 语法 == startswith()方法语法: <sample title="" desc="" lang="python" hererun="1"> str.startswith(substr, beg=0,end=len(string)); </sample> == 参数 == * str -- 检测的字符串。 * substr -- 指定的子字符串。 * strbeg -- 可选参数用于设置字符串检测的起始位置。 * strend -- 可选参数用于设置字符串检测的结束位置。 == 返回值 == 如果检测到字符串则返回True,否则返回False。 以下实例展示了startswith()函数的使用方法: == React 实例 == <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 str = "this is string example....wow!!!" print (str.startswith( 'this' )) # 字符串是否以 this 开头 print (str.startswith( 'string', 8 )) # 从第九个字符开始的字符串是否以 string 开头 print (str.startswith( 'this', 2, 4 )) # 从第2个字符开始到第四个字符结束的字符串是否以 this 开头 </sample> 以上实例输出结果如下: <sample title="" desc="" lang="python" hererun="1"> True True False </sample> [[python3 string|Python3 字符串]]
返回至“
Python3 string startswith
”。
上一节:
Python3_string_splitlines
下一节:
Python3_string_strip