2020年10月12日 星期一

Python Learning Note

Source : NTU Python Class, 程式語言教學誌Python 3.5.1 documentation

Table:
  • Python 特色 
  • Python 2.x VS. Python 3.x
  • Object
  • Data Type
numeric types -- int, float, complex
sequence types -- list, tuple, range, string
set types -- set, frozenset
dictionary type -- dict
  • Boolean  
  • Control Flow Tools
  • 字串處理
  • 字串函數處理與格式化
  • Function
  • Built-in Functions
  • Yield產生器
  • Class
  • 封裝 (encapsulation) 
  • 繼承 (inheritance) 
  • 多型 (polymorphism)
  • Exception Handling
  • raise
  • print()
  • open()
  • read()
  • readline()
  • readlines()
  • Module
  • Standard Library
  • 網頁抓取與解析
  • Python_pandas
  • Introduce to Data Structures
  • Python_numpy
  • Numpy for Matlab users
  • numpy.ndarray.shape
  • numpy.unique
  • numpy.meshgrid 
  • numpy.ravel 
  • numpy.cov 
  • numpy.linalg (Linear algebra)
  • matplotlib
  • matplotlib.color
  • matplotlib.imshow vs cv2.imshow 
  • Regular expression operations
  • .py to exe
  • Pyinstaller
  • Python_GUI
  • Python_Tkinter
  • Python_OpenCV
  • Python_Python_scikit_learn
  • threading — Thread-based parallelism
  • Coding Style
  • conda install vs pip install
  • set virtual environment for jupyter lab

 

附錄:








python_Note23

conda install vs pip install
conda install 與 pip install 的差別


pip : only install the package you select

conda : not only install the package you select, but also install other packages or lib that the selected package will need. For example, "conda install tensorflow-gpu" will install cudatoolkit and cudn, and only be linked in the (virtual)environment.

pip : 只安裝該package

conda 會安裝該package所需要的package,甚至lib,例如tensorflow-gpu版,會一併安裝cudatoolkit和cudnn,且只會在該環境,其他環境不會受影響。


set virtual environment for jupyter lab
設定虛擬環境給jupyter lab使用


base : conda create -n py36 python=3.6 # create new virtual environment, named py36, and python kernel =3.6

py36 : pip install ipykernel jupyterlab # change to py36 environment and install ipykernel (jupyterlab is not necessary

py36 : python -m ipykernel install --user --name py36 --display-name tf15 # install/link the py36 kernel to jupyter lab, and name it as tf15


補充:重開機後base 的tf15無法呼叫GPU,原因不明,但的確是連到tf1.15版本,而在py36就可以呼叫到GPU,一切正常。
base: jupyter lab   # 在base可以連動py36的tf15 
in base environment, jupyter lab's tf15 is linked to py36

py36 : jupyter lab # 顯示python 和 tf15,但兩個都是指向py36
in py36 environment, although jupyer lab displays tf15 and python,both 2 are linked to py36.