看板 [ Python ]
討論串[問題] import 問題
共 3 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者sunrise0406 (baker)時間14年前 (2010/12/06 13:09), 編輯資訊
0
0
0
內容預覽:
不同點在於使用import math 時,math是全域變數,math.fabs就像是使用變數的屬性. 使用from math import *時,math底下的函式都是全域變數,直接使用函式名稱即可。. 另外,根據Python Web Development with Django [Forcie

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者uranusjr (←這人是超級笨蛋)時間14年前 (2010/12/06 00:21), 編輯資訊
0
0
0
內容預覽:
>>> def floor(x):. ... return x. .... >>> import math. >>> x = -5.5. >>> math.floor(x). -6.0. >>> floor(x). -5.5 # 名稱空間讓兩個函數不衝突. =====================
(還有224個字)

推噓0(0推 0噓 6→)留言6則,0人參與, 最新作者uranusjr (←這人是超級笨蛋)時間14年前 (2010/12/05 23:39), 編輯資訊
0
0
0
內容預覽:
>>> import math. >>> x = -5.5. >>> y = math.floor(x). >>> y. -6.0. >>> z = math.fabs(y). >>> z. 6.0. ===========================. >>> from math import
(還有398個字)
首頁
上一頁
1
下一頁
尾頁