每天資訊Python基礎程式設計(2)

菜單

Python基礎程式設計(2)

分享興趣,傳播,增長見聞,快樂!

少年易老學難成,一寸光陰不可輕。

Python基礎程式設計(2)

Python基礎程式設計(2)

關於Python

Python基礎程式設計(2)

LearningYard新學苑

Python基礎程式設計(2)

Python由

荷蘭

數學

計算機科學

研究學會的

Guido van Rossum

於1990 年代初設計,作為一門叫做

ABC語言

的替代品。Python提供了高效的高階

資料結構

,還能簡單有效地

面向物件

程式設計。Python語法和動態型別,以及

解釋型語言

的本質,使它成為多數平臺上寫

指令碼

和快速開發應用的程式語言,隨著版本的不斷更新和語言新功能的新增,逐漸被用於獨立的、

大型專案

的開發。

Python強大的庫函式

Python擁有一個龐大,且還在不斷拓展的標準庫。它可以幫助處理各種工作,包括

正則表示式

、文件生成、

單元測試

執行緒

、資料庫、網頁瀏覽器、CGI、FTP、電子郵件、XML、XML-RPC、HTML、WAV檔案、密碼系統、GUI(

圖形使用者介面

)、Tk和其他與系統有關的操作。這被稱作Python的“功能齊全”理念。除了標準庫以外,還有許多其他高質量的庫,如wxPython、Twisted和Python影象庫等等。

列表、字典與集合

1、 列表

Python 內建的一種資料型別是列表(list):list 是一種有序的集合,可以新增和刪除

其中元素。

序列是 Python 中最基本的資料結構。序列中的每個元素都有一個索引,即在序列中的

位置,第一個索引是 0,第二個索引是 1,依此類推。

此外,Python 已經內建確定序列的長度以及確定最大和最小元素的方法。列表是最常

用的 Python 資料型別,它可以作為一個方括號內的逗號分隔值出現。列表的資料項不需要

具有相同的型別建立一個列表,只要把逗號分隔的不同的資料項使用方括號括起來即可。

List 包含以下函式:

Python基礎程式設計(2)

list 包含以下方法:

Python基礎程式設計(2)

Python基礎程式設計(2)

2、 字典

Python 內建了字典(dict):dict 全稱 Dictionary,在其他語言中也稱為 map,使用鍵

-值(key-value)儲存,具有極快的查詢速度。

Python 字典包含了以下內建函式:

Python基礎程式設計(2)

Python 字典包含了以下內建方法:

Python基礎程式設計(2)

Python基礎程式設計(2)

3、 集合

集合(set)和 dict 類似,也是一組 key 的集合,但不儲存 value。

集合中的元素有三個特徵:

1。 確定性:集合中的元素必須是確定的;

2。 互異性:集合中的元素互不相同,例如:集合 A={1,a},則 a 不能等於 1);

3。 無序性:集合中的元素沒有先後之分,如:{3,4,5}和{3,5,4}算作同一個集合。

set 和 dict 的唯一區別僅在於沒有儲存對應的 value,但是,set 的原理和 dict 一樣。

所以,同樣不可以放入可變物件,因為無法判斷兩個可變物件是否相等,也就無法保證 set

內部“不會有重複元素”。

set 與數學中的集合類似,是無序的和無重複元素的集合。因此,在 Python 中,set 可

以進行交集、並集、補集等操作。

Python基礎程式設計(2)

Python基礎程式設計(2)

英文翻譯

The English translation

Share interests, spread happiness, increase knowledge, leave beauty! Dear, this is LearningYard School。 Today the editor brings you:

Python and its library functions——Pandas

About the Python

Python was designed in the early 1990s by Guido van Rossum of the Dutch Institute for Mathematical and Computer Science research as an alternative to a language called ABC。 Python provides efficient high-level data structures, as well as simple and efficient object-oriented programming。 Python syntax and dynamic typing, as well as the nature of the interpreted language, make it a programming language for scripting and rapid application development on most platforms。 As versions continue to be updated and new features are added to the language, it is increasingly being used for independent, large project development。

Python‘s powerful library functions

Python has a large and growing standard library。 It can help with a variety of jobs, including regular expressions, document generation, unit testing, threading, databases, Web browsers, CGI, FTP, E-mail, XML, XML-RPC, HTML, WAV files, password systems, GUIs (graphical user interfaces), Tk, and other system-related operations。 This is called Python’s “full-featured” idea。 In addition to the standard library, there are many other high-quality libraries, such as the wxPython, Twisted, and Python image libraries, to name a few。

如果您對今 天的文章有獨特的意見,歡迎給我們留言。

讓我們相約明天,祝您今天過得開心快樂!

本文由LearningYard學園原創,

部分圖片、影片素材來源網路,如侵權請溝通。

參考資料:

百度圖片(圖片)

百度百科(文字)