看板 Python 關於我們 聯絡資訊
請問python 有類似 C #ifdef debug_on 這種開啟的方法嗎? 還是要換個思維? #ifdef debug_on #define LOG(...) do{}while(0) #else #define LOG(...) print(...) #endif -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.127.81.37 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1401384994.A.05F.html ※ 編輯: soeasyright (59.127.81.37), 05/30/2014 01:36:52
gozule:把debug_on當做是一個變數,在程式裡面用if判斷 05/30 01:44
soeasyright:我發現問錯了 應該是要問#define 這樣轉變的才對Orz 05/30 02:01
soeasyright:! 我好像懂了 05/30 02:03
def log(*i,**j) if debug_on: print(*i,**j) else: pass ※ 編輯: soeasyright (59.127.81.37), 05/30/2014 02:07:42
jcfrank:Python 的method不是可以被redefine嗎? 05/30 02:09
walelile:logging? 05/30 02:15
walelile:中文教學 http://www.icoding.co/2012/08/logging-html 05/30 02:17
soeasyright:喔喔!!! 新手上路 謝謝大家 正在看logging 再次謝謝 05/30 02:21