###### 112-08-04 中央大學 企業資源規劃暨大數據分析中心 #### 開課期間:112年8月4日~112年9月1日(每週五) 共20小時 ### 課程目標 * 程式邏輯思考。 * Python基本功。 * 實務範例演練。 ### 課程架構  #### 課程講義 * 課程教學資料本體,包含上課全部教學說明與範例,以及補充教材與練習。 * 持續更新,跟上最新版本資訊。 #### 上課記錄 * 記錄上課中不在講義內的額外參考資訊。 * 學員問題的解答或補充。 #### 強化學習 * 額外教學補充。 * 課程專屬群組討論。 ### 課程大綱與講義 | 課程 | 大綱 | 講義 | | --- | --- | --- | | 第一天 | * Pandas檔案處理:讀取、轉換、寫入 <br> (txt、csv、xml、json)<br>* Pandas資料結構 - Series操作<br>* Pandas資料結構 - DataFrame操作<br>* CRUD<br>* 資料定位<br>* 過濾、資料合併 | * [Pandas基礎](https://hackmd.io/@aaronlife/python-topic-pandas) | | 第二天 | * Pandas資料操作<br>* Grouping、Apply、Aggregation<br>* Pandas實戰<br>* Windows檔案處理<br>* FTP的檔案操作 | * [檔案系統操作](https://hackmd.io/@aaronlife/python-topic-file-management)<br>* [SFTP操作](https://hackmd.io/@aaronlife/python-topic-sftp) | | 第三天 | * Excel基礎<br>* 活頁簿、工作表建立<br>* 欄位、列、儲存格操作<br>* Excel資料操作CRUD<br>* 移動、合併、切片<br>* 儲存格調整: 屬性、樣式 | * [Excel基礎](https://hackmd.io/@aaronlife/python-topic-excel) | | 第四天 | * Excel圖表<br>* 長條圖、橫條圖<br>* 圓餅圖、環圈圖<br>* 折線圖、區域圖<br>* Excel實戰<br>* Windows排程<br>* 爬蟲基本功: HTML + CSS | * [定時任務、自動化執行](https://hackmd.io/@aaronlife/python-topic-scheduler) | | 第五天 | * 靜態網頁爬蟲(BeautifulSoup)<br>* 網頁內容分析與解析<br>* 工具介紹<br>* bs4套件操作<br>* 靜態爬蟲實務範例<br>* 動態網頁爬蟲(Selenium)<br>* JSON解析<br>* 其他相關常識<br>* 動態爬蟲實務範例 | * [Python爬蟲基礎](https://hackmd.io/@aaronlife/python-topic-beautifulsoup)<br>* [Python動態網頁爬蟲](https://hackmd.io/@aaronlife/python-topic-selenium)<br>* [實戰練習I](https://hackmd.io/@aaronlife/python-topic-crawler)<br>* [爬蟲技巧](https://hackmd.io/@aaronlife/python-topic-crawler-knowledge) | ### 上課記錄 https://hackmd.io/@aaronlife/ncu-python-amkor ## 補充教材 #### 開發環境 - 安裝開發環境Visual Studio Code + Jupyter:https://hackmd.io/@aaronlife/dev-env-visual-studio-code - 安裝開發環境Anaconda:https://hackmd.io/@aaronlife/dev-env-anaconda - 線上環境Colab:https://colab.research.google.com/ #### Python語言基礎 * [Python介紹](https://hackmd.io/@aaronlife/python-00-about) * [Python變數、資料型態、運算子](https://hackmd.io/@aaronlife/python-01-basic) * [Python流程控制](https://hackmd.io/@aaronlife/python-02-flow-control) * [Python資料結構](https://hackmd.io/@aaronlife/python-03-data-structures) * [Python類別與物件](https://hackmd.io/@aaronlife/python-04-object) #### 練習 [Python基礎練習](https://hackmd.io/@aaronlife/ncu-python-exam) [Python基礎練習 - 參考答案](https://hackmd.io/@aaronlife/ncu-python-exam-ref) #### 這些可以學一下 * 工程師專屬文件格式Markdown:https://markdown.tw/ * 網頁標籤基礎HTML:https://hackmd.io/@aaronlife/html * 網頁資料傳輸格式JSON:https://hackmd.io/@aaronlife/python-json * 有標格概念的檔案格式CSV:https://hackmd.io/@aaronlife/python-csv * 網頁傳輸協定:https://hackmd.io/@aaronlife/http * Python正規表達式:https://hackmd.io/@aaronlife/regular-expression #### Python實務挑戰:用Python寫些有用的程式 - 取得桃園市UBike即時資訊:https://hackmd.io/@aaronlife/python-topic-Taoyuan-ubike * 建立COVID-19最新資訊網頁:https://hackmd.io/@aaronlife/python-ex-covid19 * COVID-19資料視覺化:https://hackmd.io/@aaronlife/python-topic-covid19-visualization * 爬取台灣銀行匯率資訊:https://hackmd.io/@aaronlife/python-ex-爬取匯率資料 * 爬取Google Trend資料:https://hackmd.io/@aaronlife/python-ex-google-trend * 用tkinter來打造GUI BMI計算機:https://hackmd.io/@aaronlife/python-ex-tkinter #### 講義下載 ##### 安裝套件 ```bash= $ pip3 install pysftp ``` ##### 程式碼 ```python= import pysftp import os def download_folder(sftp, folder_name): if not sftp.exists(folder_name): print(f'遠端目錄:{folder_name} 不存在,無法下載') return if not os.path.exists(folder_name): print(f'本地目錄:{folder_name} 不存在,建立目錄') os.makedirs(folder_name) files = sftp.listdir(remotepath=folder_name) for i in files: if sftp.isdir(folder_name + '/' + i): download_folder(sftp, folder_name + '/' + i) else: sftp.get(folder_name + '/' + i, folder_name + '/' + i) host = '' username = '' password = '' cnopts = pysftp.CnOpts() hostkeys = None if cnopts.hostkeys.lookup(host) == None: print("發現新的SFTP站台,將允許該站台憑證 .....") # 將新的憑證存到變數裡 hostkeys = cnopts.hostkeys # 將憑證檢查暫時關閉,避免第一次無法連線, cnopts.hostkeys = None with pysftp.Connection(host, username=username, password=password, cnopts=cnopts) as sftp: # 加入新的憑證 if hostkeys != None: print("連線到該新的SFTP站台並儲存該站台憑證") hostkeys.add(host, sftp.remote_server_key.get_name(), sftp.remote_server_key) hostkeys.save(pysftp.helpers.known_hosts()) download_folder(sftp, '講義') ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up