2011年10月19日 星期三

[Learning Python] Reference

  • Reference :






  •              1. Programming in Python 3: A Complete Introduction to the Python Language 
                   2. Learning Python: Powerful Object-Oriented Programming (4th Edition)    
                   3. Learning Python,3rd Edition 
                   4. Python for Unix and Linux System Administration 
                   5. Python Cookbook (2nd Editiom)
                   6. Python Testing Cookbook
                   7. The Python Standard Library by Example (Developer's Library)
                   8. Programming Python(4th Edition)
                   9. A Byte of Python v1.92 (for Python 3.0 
                 10. Python Documentation 
                 11. The Python Standard Library 
                 12. PyPI - the Python Package Index
                 13. Python 3 技術手冊
                 14. Beginning Python: Using Python 2.6 and Python 3.1 

    [Learning Python] Collection Data Type -- List(列表)

    1.Collection Data Type and Sequence Data Type

        由於『List』中的元素可以是不同的資料型別物件,所以與『Tuple』都是屬於『Collection Data Type』; 同時,『List』中的各元素的存放方式與『String』一樣都是以循序的方式存放,所以『List』也是屬於『Sequence Data Type』的一種,因此只要是『Sequence Data Type』可以用的操作方法,如『Index』、『Slice』...等,都可以用在『List』上面。


    2.可直接變更內容

        『String』與『Tuple』是屬於不可變的資料型別,所有看起來像是變更內容的操作其實是變成一個新物件再將原變數參照到新物件。

         而『List』就可以直接變更原『List Object』的內容,所以有一些『List』專用的內容原地變更用操作並不能用在同為『Sequence Data Type』的『String』與『Tuple』身上。


    3.每一個元素都是『Reference(參照)』

        與『Tuple』一樣,『List』中各元素的值實際上是存放在『List』中各元素所『Reference』過去的物件那邊,而『List』這邊存放的是各元素的『Reference』。

    4.建立『 List』的語法

        建立『 List』的語法如下,

    ListName=[Item1,Item2,Item3....]       




        事實上用『[....]』 括起來,其中的元素用『,』隔開,Python就知道這個物件是『List』。

    [Item1,Item2,Item3....]                
    Powered By Blogger