<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國際加速解決方案。 廣告
                前面已經洋洋灑灑地介紹了不少數據類型。不能再不顧一切地向前沖了,應當總結一下。這樣讓看官能夠從總體上對這些數據類型有所了解,如果能夠有一覽眾山小的感覺,就太好了。 下面的表格中列出了已經學習過的數據類型,也是python的核心數據類型之一部分,這些都被稱之為內置對象。 > 對象,就是你面對的所有東西都是對象,看官要逐漸熟悉這個稱呼。所有的數據類型,就是一種對象。英文單詞是object,直接的漢語意思是物體,這就好像我們在現實中一樣,把很多我們看到和用到的都可以統稱為“東西”一樣。“東西”就是“對象”,就是object。在編程中,那個所謂面向對象,也可以說成“面向東西”,是嗎?容易有歧義吧。 | 對象類型 | 舉例 | | --- | --- | | int/float | 123, 3.14 | | str | 'qiwsir.github.io' | | list | [1, [2, 'three'], 4] | | dict | {'name':"qiwsir","lang":"python"} | | tuple | (1, 2, "three") | | set | set("qi"), {"q", "i"} | 不論任何類型的數據,只要動用dir(object)或者help(obj)就能夠在交互模式下查看到有關的函數,也就是這樣能夠查看相關幫助文檔了。舉例: ~~~ >>> dir(dict) ~~~ 看官需要移動鼠標,就能夠看全(下面的本質上就是一個list): ~~~ ['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values', 'viewitems', 'viewkeys', 'viewvalues'] ~~~ 先略過__雙下劃線開頭的哪些,看后面的,就是dict的內置函數。至于詳細的操作方法,通過類似help(dict.pop)的方式獲得。這是前面說過的,再說一遍,加深印象。 **我的觀點:學習,重要的是學習方法,不是按部就班的敲代碼。** 今天既然是復習,就要在原來基礎上提高一點。所以,也要看看上面那些以雙下劃線__開頭的東西,請看官找一下,有沒有發現這個:"__doc__"。這是什么,它是一個文件,里面記錄了對當前所查看的對象的詳細解釋。可以在交互模式下這樣查看: ~~~ >>> dict.__doc__ ~~~ 顯示應該是這樣的: > "dict() -> new empty dictionary\ndict(mapping) -> new dictionary initialized from a mapping object's\n (key, value) pairs\ndict(iterable) -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] = v\ndict(**kwargs) -> new dictionary initialized with the name=value pairs\n in the keyword argument list. For example: dict(one=1, two=2)" 注意看上面亂七八糟的英文中,是不是有\n符號,這是什么?前面在講述字符串的時候提到了轉義符號\,這是換一行。也就是說,如果上面的文字,按照排版要求,應該是這樣的(當然,在文本中,如果打開,其實就是排好版的樣子)。 > "dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)" 可能排版還是不符合愿意。不過,看官也大概能看明白了。我要說的不是排版,要說的是告訴看官一種查看某個數據類型含義的方法,就是通過obj.__doc__文件來看。 嘿嘿,其實有一種方法,可以看到排版的結果的: ~~~ >>> print dict.__doc__ dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) ~~~ 上面那么折騰一下,就是為了湊篇幅,不然這個總結的東西太少了。 總之,只要用這種方法,你就能得到所有幫助文檔,隨時隨地。如果可以上網,到官方網站,是另外一種方法。 還需要再解釋別的嗎?都多余了。唯一需要的是看官要能會點英語。不過我相信看官能夠讀懂,我這個二把刀都不如的英語水平,還能湊合看呢,何況看官呢? 總結不是意味著結束,是意味著繼往開來。精彩還在后面,這里只是休息。今天還是周日。 ## 主日崇拜 腓立比書 Philippians(3:13-14) > Brethren, I count not myself to have apprehended: but this one thing I do, forgetting those things which are behind, and reaching forth unto those things which are before, I press toward the mark for the prize of the high calling of God in Christ Jesus. > > 弟兄們、我不是以為自己已經得著了.我只有一件事、就是忘記背後努力面前的, 向著標竿直跑、要得神在基督耶穌裡從上面召我來得的獎賞 。 ### 忘記背后,努力面前,向著標桿直跑
                  <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>

                              哎呀哎呀视频在线观看