<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 更多字符串的內容 我們已經在前面詳細討論了字符串。我們還需要知道什么呢?那么,你是否知道字符串也是對象,同樣具有方法。這些方法可以完成包括檢驗一部分字符串和去除空格在內的各種工作。 你在程序中使用的字符串都是`str`類的對象。這個類的一些有用的方法會在下面這個例子中說明。如果要了解這些方法的完整列表,請參見`help(str)`。 ``` #!/usr/bin/python # Filename: str_methods.py name = 'Swaroop' # This is a string object if name.startswith('Swa'): ????print 'Yes, the string starts with "Swa"' if 'a' in name: ????print 'Yes, it contains the string "a"' if name.find('war') != -1: ????print 'Yes, it contains the string "war"' delimiter = '_*_' mylist = ['Brazil', 'Russia', 'India', 'China'] print delimiter.join(mylist) ``` (源文件:[code/str_methods.py](code/str_methods.py)) ## 輸出 ``` $ python str_methods.py Yes, the string starts with "Swa" Yes, it contains the string "a" Yes, it contains the string "war" Brazil_*_Russia_*_India_*_China ``` ## 它如何工作 這里,我們看到使用了許多字符串方法。`startwith`方法是用來測試字符串是否以給定字符串開始。`in`操作符用來檢驗一個給定字符串是否為另一個字符串的一部分。 `find`方法用來找出給定字符串在另一個字符串中的位置,或者返回-1以表示找不到子字符串。`str`類也有以一個作為分隔符的字符串`join`序列的項目的整潔的方法,它返回一個生成的大字符串。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看