内容标题2

  • <tr id='pLGmMQ'><strong id='pLGmMQ'></strong><small id='pLGmMQ'></small><button id='pLGmMQ'></button><li id='pLGmMQ'><noscript id='pLGmMQ'><big id='pLGmMQ'></big><dt id='pLGmMQ'></dt></noscript></li></tr><ol id='pLGmMQ'><option id='pLGmMQ'><table id='pLGmMQ'><blockquote id='pLGmMQ'><tbody id='pLGmMQ'></tbody></blockquote></table></option></ol><u id='pLGmMQ'></u><kbd id='pLGmMQ'><kbd id='pLGmMQ'></kbd></kbd>

    <code id='pLGmMQ'><strong id='pLGmMQ'></strong></code>

    <fieldset id='pLGmMQ'></fieldset>
          <span id='pLGmMQ'></span>

              <ins id='pLGmMQ'></ins>
              <acronym id='pLGmMQ'><em id='pLGmMQ'></em><td id='pLGmMQ'><div id='pLGmMQ'></div></td></acronym><address id='pLGmMQ'><big id='pLGmMQ'><big id='pLGmMQ'></big><legend id='pLGmMQ'></legend></big></address>

              <i id='pLGmMQ'><div id='pLGmMQ'><ins id='pLGmMQ'></ins></div></i>
              <i id='pLGmMQ'></i>
            1. <dl id='pLGmMQ'></dl>
              1. <blockquote id='pLGmMQ'><q id='pLGmMQ'><noscript id='pLGmMQ'></noscript><dt id='pLGmMQ'></dt></q></blockquote><noframes id='pLGmMQ'><i id='pLGmMQ'></i>

                您所在的位置:首页>新闻动态>新闻内容

                Python startswith() 函数 判断字符串开头

                  函数:startswith()
                  作用:判断字符串眼中充滿了絕望是否以指定字符或子字符串开头
                  一、函数说明
                  语法:string.startswith(str, beg=0,end=len(string))
                  或string[beg:end].startswith(str)
                  参数说明:
                  string:  被检〗测的字符串
                  str:      指定的字符或者子字符串。(可以使用元¤组⌒ ,会逐一匹配)
                  beg:    设置字符串检测的起始■位置(可选)
                  end:    设置字符串检测嗡的结束位置(可选)
                  如果存在参数 beg 和 end,则在指定范围内检查,否则在整个字符串中检查
                  返回值
                  如果看著半空中剩余检测到字符串,则返回True,否则返回False。默→认空字符为True
                  函数解析:如果字符串string是以str开始,则返回True,否则返回False
                  二、实例
                  >>> s = 'hello good boy doiido'
                  >>> print s.startswith('h')
                  True
                  >>> print s.startswith('hel')
                  True
                  >>> print s.startswith('h',4)
                  False
                  >>> print s.startswith('go',6,8)
                  True
                  #匹配空★字符集
                  >>> print s.startswith('')
                  True
                  #匹配元组
                  >>> print s.startswith(('t','b','h'))
                  True
                  常用环境:用于if判断
                  >>> if s.startswith('hel'):
                  print "you are right"
                  else:
                  print "you are wrang"
                  you are right

                上一篇:五种 - 方法让你的python运□行的更快...
                下一篇:云计算提速 您的服务器准备好了吗?...

                金源在线客」服

                QQ在线咨询

                咨询电话
                010-83650488

                在线咨询

                在线咨询

                电话咨询