My Python

顯示中文

# -*- coding: utf-8 -*-

參考資料: https://blog.gtwang.org/programming/python-chinese-comments-utf8-encoding/

#讓這支程式在作為module被其他人當作模組呼叫與直接執行有所區別
#直接執行    -> name的名稱就是main
#模組呼叫    -> name則為test


#test.py
if __name__ == __main__:
    print(__name__)
    main()

參考來源

Input

raw_input() --> 輸入內容會被視為字串型態

input() --> 輸入內容會被視為變數、公式等

參考來源

lambda

方便的小function,可用於簡單的運算或判斷

map

操作所有元素

filter

根據條件過濾元素

參考來源

檔案操作

刪除

http://wiki.alarmchang.com/index.php?title=Python_刪除目錄和下面的所有檔案_使用_shutil.rmtree

參考連結: http://www.victorgau.com/?p=5586

檔案名稱與路徑

參考連結: https://blog.csdn.net/xiemanR/article/details/72728142

檔案複製

https://blog.csdn.net/qq_37634812/article/details/79206025

https://read01.com/zh-tw/DmjLP5.html#.Wtg_b4huaUk

https://itw01.com/VUUFESS.html

讀取與寫入

https://blog.csdn.net/ztf312/article/details/47259805

檔案大小

https://codeday.me/bug/20170321/6057.html

https://blog.csdn.net/u013419465/article/details/40583031

Exception

輸出詳細的錯誤訊息

路徑

windows vs linux

https://ephrain.net/python-使用-os-path-處理路徑問題/

獲取作業系統

https://imsardine.wordpress.com/2012/06/12/python-programming-environment-os/

print

sep = 指定分隔符號

end = 指定結束符號

flush = True (顯示緩衝區內容)

https://tw.saowen.com/a/2c71b8fcf2846c5f460c64db0065b1e3926276d2bc17ddcd140d2e9ae040a006

查詢套件

List all installed packages - 列出所有已安裝的套件

$ pip freeze

Check specify package version - 查看某套件版本

$ pip freeze | grep Django

https://whhnote.blogspot.com/2013/05/python-list-pip-installed-packages-pip.html

反編譯

簡介

https://www.itread01.com/content/1546897339.html

https://aji.tw/%E5%A6%82%E4%BD%95%E4%BF%9D%E8%AD%B7python%E5%8E%9F%E5%A7%8B%E7%A2%BC/

https://www.zhihu.com/question/20069661

https://kknews.cc/zh-tw/code/2xojaxr.html

Last updated

Was this helpful?