SlideShare a Scribd company logo
1 of 9
關於import
python
1.import math
此方法在使用math模板的函式時
需打上math
Ex: math.gcd(a,b)
2.from math import *
此方法在使用math模組時
可以省略math
Ex: gcd(a,b)
注意:用此方法import兩個以上的模組,如果模組裡的函式名
有重複,會被後import的模組覆蓋重複的函式
3.import math as abc
此方法是將math模組
取別名叫做abc
Ex: abc.gcd(a,b)
如同 math.gcd(a,b)
關於常用的library
(個人推薦)
1.copy
其中一個函式
copy.copy(x)
Return a shallow copy of x.
2.array
其中一個函式
array.append(x)
Append a new item with value x
to the end of the array.
3.random
其中一個函式
random.choice(seq)
Return a random element
from the non-empty sequence seq
4.statistics
其中一個函式
statistics.mean(data)
Return the sample arithmetic mean
of data, a sequence or iterator
of real-valued numbers.

More Related Content

What's hot

What's hot (20)

第3章矩阵及其运算
第3章矩阵及其运算第3章矩阵及其运算
第3章矩阵及其运算
 
Python - Matplotlib basic - v01
Python - Matplotlib basic - v01Python - Matplotlib basic - v01
Python - Matplotlib basic - v01
 
Ch9 教學
Ch9 教學Ch9 教學
Ch9 教學
 
Ppt 51-77
Ppt 51-77Ppt 51-77
Ppt 51-77
 
P127 135 new
P127 135 newP127 135 new
P127 135 new
 
Appendix B 教學
Appendix B 教學Appendix B 教學
Appendix B 教學
 
T3
T3T3
T3
 
Scilab Chap1
Scilab Chap1Scilab Chap1
Scilab Chap1
 
Ch11 教學
Ch11 教學Ch11 教學
Ch11 教學
 
Matlab 在機率與統計的應用
Matlab 在機率與統計的應用Matlab 在機率與統計的應用
Matlab 在機率與統計的應用
 
Ch1 教學
Ch1 教學Ch1 教學
Ch1 教學
 
Ppt 26-50
Ppt 26-50Ppt 26-50
Ppt 26-50
 
Ch10 教學
Ch10 教學Ch10 教學
Ch10 教學
 
Ch5
Ch5Ch5
Ch5
 
Ch12 範例
Ch12 範例Ch12 範例
Ch12 範例
 
Sym py edu
Sym py eduSym py edu
Sym py edu
 
Python speed up with numba
Python speed up with numbaPython speed up with numba
Python speed up with numba
 
Lab2
Lab2Lab2
Lab2
 
Ppt 1-50
Ppt 1-50Ppt 1-50
Ppt 1-50
 
Lua 30+ Programming Skills and 20+ Optimization Tips
Lua 30+ Programming Skills and 20+ Optimization TipsLua 30+ Programming Skills and 20+ Optimization Tips
Lua 30+ Programming Skills and 20+ Optimization Tips
 

關於Import