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