關(guān)于我們
書單推薦
新書推薦
|
Python基礎(chǔ)教程 讀者對象:計算機應(yīng)用技術(shù)、軟件技術(shù)、云計算、大數(shù)據(jù)、人工智能等專業(yè)高職學生
本教材以 Windows操作系統(tǒng)為平臺,系統(tǒng)講解 Python3的基礎(chǔ)知識。全書共 11章,主要介紹了 Python基本語法、字符串、列表、元組、字典、文件的讀寫、函數(shù)與模塊等基礎(chǔ)知識。首先介紹了 Python的特點、發(fā)展及推薦學習方法,然后講授了 Python基礎(chǔ)語法、流程控制語句、數(shù)據(jù)類型、函數(shù)、模塊、面向?qū)ο蟆⑽募幚、異常處理、?shù)據(jù)庫操作,最后增加了全國計算機等級考試二級 Python語言程序設(shè)計考試中所要求的第三方庫相關(guān)知識等。教材根據(jù)“自主式一體化教學”模式,對教材的構(gòu)成要素進行調(diào)整,按照 Python的有關(guān)知識由淺入深、從易到難進行編寫,并在每章后布置實訓(xùn)與練習,實現(xiàn)“教、學、做”一體,從而切實提高學生的持續(xù)發(fā)展能力。本教材力求為數(shù)據(jù)采集及分析提供全面的語言基礎(chǔ),同時也考慮到部分學有余力的同學參加全國計算機等級考試的要求,補充了全國計算機等級考試二級 Python語言程序設(shè)計考試大綱規(guī)定的知識,故也適合作為全國計算機等級考試二級考試 Python語言程序設(shè)計考試參考用書。為提升學習效果,教材結(jié)合實際應(yīng)用提供了大量的案例進行說明和訓(xùn)練,并配以完善的學習資料和支持服務(wù),包括教學大綱、教學進度表、教學 PPT、案例源碼等,為讀者提供全方位的學習服務(wù)。
周勝,男,高級實驗師,擔任軟件專業(yè)負責人,近五年來,課程及資源建設(shè)完成如下:2013年主持完成《ASP.NET動態(tài)網(wǎng)頁開發(fā)》課程信息化建設(shè);2014年完成《計算機組裝與維護實訓(xùn)指導(dǎo)書》校本教材建設(shè);2015年完成《XAML基礎(chǔ)教程》工學結(jié)合校本教材建設(shè);2016年完成《大學計算機基礎(chǔ)教程》編寫及出版工作;2018年上半年完成《Python數(shù)據(jù)分析程序基礎(chǔ)》工學結(jié)合校本教材建設(shè)。
目錄
第 1章初識 Python ·························································································· 1 1.1認識 Python ····························································································· 1 1.1.1 Python初識 ···················································································· 2 1.1.2 Python的特點及應(yīng)用領(lǐng)域 ·································································· 2 1.1.3 Python的學習方法 ··········································································· 3 1.2搭建環(huán)境 ································································································· 4 1.2.1 Python下載 ···················································································· 5 1.2.2 Python IDLE開發(fā)環(huán)境 ······································································· 7 1.2.3 PyCharm開發(fā)環(huán)境 ··········································································· 8 1.2.4 Anaconda3開發(fā)環(huán)境 ········································································10 1.3打包發(fā)布 ································································································16 1.3.1 pip包管理工具 ···············································································16 1.3.2 PyInstaller······················································································19 1.4實訓(xùn) 1:使用環(huán)境搭建 ··············································································22【本章習題】 ··································································································22 第 2章編程基礎(chǔ) ·····························································································24 2.1認識 Python程序和中文編碼 ······································································24 2.2 Python固定語法 ······················································································25 2.2.1 Python代碼塊 ················································································25 2.2.2 Python行處理 ················································································26 2.2.3 Python標識符及保留字 ····································································28 2.3 Python基本輸入輸出 ················································································30 2.3.1用戶輸入 ·······················································································30 2.3.2屏幕輸出 ·······················································································32 2.4 Python變量和數(shù)據(jù)類型 ·············································································33 2.4.1變量和賦值 ····················································································34 基礎(chǔ)教程 2.4.2簡單數(shù)據(jù)類型 ·················································································35 2.4.3類型轉(zhuǎn)換 ·······················································································40 2.5 Python的對象和變量 ················································································41 2.5.1對象的類型與身份 ···········································································42 2.5.2變量引用對象 ·················································································42 2.5.3共享引用 ·······················································································43 2.6 Python運算符 ·························································································45 2.6.1算術(shù)運算符 ····················································································45 2.6.2比較運算符 ····················································································47 2.6.3賦值運算符 ····················································································48 2.6.4位運算符 ·······················································································49 2.6.5邏輯運算符 ····················································································50 2.6.6成員運算符 ····················································································51 2.6.7身份運算符 ····················································································52 2.6.8運算符優(yōu)先級 ·················································································52 2.7實訓(xùn) 2:班級競選統(tǒng)計 ··············································································54【本章習題】 ··································································································56 第 3章控制流程 ·····························································································58 3.1條件語句 ································································································58 3.1.1 if條件語句 ····················································································59 3.1.2實踐運用 ·······················································································62 3.2循環(huán)語句 ································································································63 3.2.1循環(huán)語句概述 ·················································································63 3.2.2 while循環(huán)語句 ···············································································63 3.2.3 for循環(huán)語句 ··················································································65 3.2.4循環(huán)嵌套 ·······················································································66 3.2.5實踐運用 ·······················································································67 3.3其他語句 ································································································67 3.3.1 break語句 ·····················································································68 3.3.2 continue語句··················································································70 3.3.3 pass語句·······················································································71 3.3.4 else語句 ·······················································································71 3.4實訓(xùn) 3:數(shù)字金字塔 ·················································································73【本章習題】 ··································································································74 第 4章 Python數(shù)據(jù)類型 ···················································································76 4.1 Python序列操作 ······················································································76 4.2 Python字符串 ·························································································79 4.2.1 Python字符串操作 ··········································································80 目錄 4.2.2字符串格式化輸出 ···········································································83 4.2.3三引號 ··························································································85 4.2.4字符串函數(shù) ····················································································86 4.3 Python列表 ····························································································95 4.3.1列表概述 ·······················································································96 4.3.2列表操作 ·······················································································96 4.3.3列表函數(shù) ····················································································· 100 4.4 Python元組 ·························································································· 104 4.4.1元組概述 ····················································································· 104 4.4.2元組操作 ····················································································· 105 4.4.3元組函數(shù) ····················································································· 108 4.5 Python字典 ·························································································· 109 4.5.1字典概述 ····················································································· 110 4.5.2字典操作 ······················································································111 4.5.3字典函數(shù) ····················································································· 116 4.6 Python集合 ·························································································· 122 4.6.1集合概述 ····················································································· 122 4.6.2集合操作 ····················································································· 123 4.6.3集合函數(shù) ····················································································· 126 4.7對象的淺復(fù)制與深復(fù)制 ··········································································· 127 4.7.1淺復(fù)制 ························································································ 128 4.7.2深復(fù)制 ························································································ 129 4.8推導(dǎo)式 ································································································· 129 4.8.1列表推導(dǎo)式 ·················································································· 130 4.8.2字典推導(dǎo)式 ·················································································· 131 4.8.3集合推導(dǎo)式 ·················································································· 132 4.9實訓(xùn) 4:創(chuàng)建學生信息管理系統(tǒng)用戶數(shù)據(jù) ···················································· 132【本章習題】 ································································································ 133 第 5章代碼復(fù)用 —函數(shù) ···············································································136 5.1 Python函數(shù) ·························································································· 136 5.1.1函數(shù)概念 ····················································································· 137 5.1.2函數(shù)定義 ····················································································· 137 5.1.3函數(shù)調(diào)用 ····················································································· 138 5.1.4函數(shù)的嵌套定義 ············································································ 139 5.2 Python函數(shù)參數(shù) ···················································································· 140 5.2.1參數(shù)··························································································· 140 5.2.2參數(shù)傳遞 ····················································································· 143 5.2.3函數(shù)返回值 ·················································································· 144 5.3 Python全局變量與局部變量 ····································································· 144 基礎(chǔ)教程 5.3.1變量作用域 ·················································································· 145 5.3.2全局變量和局部變量 ······································································ 145 5.3.3 global語句 ·················································································· 146 5.3.4 nonlocal語句················································································ 147 5.4 Python匿名函數(shù) ···················································································· 148 5.5實訓(xùn) 5:使用函數(shù)編寫學生信息管理系統(tǒng) ···················································· 149【本章習題】 ································································································ 152 第 6章代碼復(fù)用 —模塊 ···············································································154 6.1模塊概述 ······························································································ 154 6.2模塊的使用 ··························································································· 155 6.2.1模塊導(dǎo)入 ····················································································· 156 6.2.2模塊定位查找 ··············································································· 158 6.2.3自定義模塊調(diào)用 ············································································ 159 6.3 Python中的包 ······················································································· 160 6.3.1包的概念 ····················································································· 160 6.3.2包使用實例 ·················································································· 161 6.4常用模塊介紹 ······················································································· 162 6.4.1時間與日期 ·················································································· 163 6.4.2 math庫······················································································· 166 6.4.3 json模塊····················································································· 168 6.5實訓(xùn) 6:使用模塊編寫學生信息管理系統(tǒng) ···················································· 170【本章習題】 ································································································ 173 第 7章 Python面向?qū)ο?·················································································175 7.1面向?qū)ο缶幊毯喗?················································································· 175 7.2類和對象 ······························································································ 177 7.2.1類的創(chuàng)建 ····················································································· 177 7.2.2實例對象 ····················································································· 179 7.2.3類的方法 ····················································································· 179 7.3類的繼承 ······························································································ 182 7.4類的方法重寫 ······················································································· 184 7.4.1方法重寫 ····················································································· 185 7.4.2運算符重載 ·················································································· 186 7.5實訓(xùn) 7:使用類編寫學生信息管理系統(tǒng) ······················································· 187【本章習題】 ································································································ 190 第 8章文件處理 ···························································································192 8.1打開和關(guān)閉文件 ···················································································· 192 8.2文件讀寫 ······························································································ 196 目錄 8.3重命名和刪除文件 ················································································· 199 8.3.1 os模塊 ······················································································· 199 8.3.2重命名和刪除文件操作 ··································································· 202 8.4 Python文件夾操作 ················································································· 203 8.5 csv文件操作 ························································································· 204 8.5.1 csv數(shù)據(jù)······················································································ 205 8.5.2讀取 csv數(shù)據(jù)··············································································· 205 8.5.3寫入.csv文件··············································································· 208 8.6實訓(xùn) 8:基于文件的學生信息管理系統(tǒng) ······················································· 209【本章習題】 ································································································ 212 第 9章異常處理 ···························································································214 9.1異常···································································································· 214 9.1.1異常概述··························································································· 215 9.1.2異常的檢測與處理 ········································································· 217 9.2拋出異常 ······························································································ 221 9.2.1拋出異常處理 ··············································································· 221 9.2.2用戶自定義異常 ············································································ 224 9.3 with語句 ····························································································· 225 9.4實訓(xùn) 9:實現(xiàn)異常處理的學生信息管理系統(tǒng) ················································· 226【本章習題】 ································································································ 231 第 10章 MySQL數(shù)據(jù)庫操作 ············································································233 10.1訪問 MySQL數(shù)據(jù)庫·············································································· 234 10.1.1 pymysql模塊安裝········································································ 234 10.1.2事務(wù)機制 ··················································································· 234 10.1.3 Python操作數(shù)據(jù)庫過程及對象 ························································ 235 10.2數(shù)據(jù)庫操作 ························································································· 236 10.2.1連接 MySQL數(shù)據(jù)庫····································································· 236 10.2.2創(chuàng)建數(shù)據(jù)庫表 ············································································· 237 10.2.3數(shù)據(jù)庫讀寫 ················································································ 239 10.3實訓(xùn) 10:基于 MySQL數(shù)據(jù)庫的學生信息管理系統(tǒng) ······································ 243【本章習題】 ································································································ 247 第 11章計算生態(tài) ··························································································249 11.1 Turtle標準庫 ······················································································· 249 11.1.1 Turtle基礎(chǔ) ················································································· 250 11.1.2 Turtle繪圖命令 ··········································································· 251 11.1.3 Turtle命令操作 ··········································································· 252 11.2 random標準庫 ····················································································· 254 Python基礎(chǔ)教程 11.2.1 random庫介紹 ············································································ 255 11.2.2 random庫常用函數(shù) ······································································ 255 11.3 jieba第三方庫 ······················································································ 257 11.3.1 jieba庫簡介 ················································································ 258 11.3.2 jieba庫的安裝 ············································································· 258 11.3.3 jieba分詞應(yīng)用 ············································································· 259 11.3.4 jieba單詞統(tǒng)計 ············································································· 259 11.4 wordcloud第三方庫 ·············································································· 260 11.4.1 wordcloud庫安裝 ········································································· 261 11.4.2 wordcloud基本使用 ······································································ 261 11.5實訓(xùn) 11:運行的時鐘 ············································································ 265【本章習題】 ································································································ 267 附錄全國計算機等級考試二級 Python語言程序設(shè)計考試大綱( 2018年版) ·············269
你還可能感興趣
我要評論
|