看板 Python 關於我們 聯絡資訊
各位版上的大大晚上好,小弟最近嘗試用jupyterlab來寫程式。 不外乎看上他的即時互動功能。但是剛開始用有些不是很習慣,甚至出現了一些有趣的 錯誤。 例如:我現在會處裡到時間資料,而我一開始就%pylab inline 當我的程式要執行時就報錯了 AttributeError Traceback (most recent call last) <ipython-input-21-d0467edf01eb> in <module>() 15 for Cdate in ER['出貨日期']: 16 logging.debug(Cdate) ---> 17 s = datetime.strftime(Cdate,'%Y-%m-%d') 18 logging.debug(s[5:7]) 19 AttributeError: module 'datetime' has no attribute 'strftime' 他有一小段說明是這樣的 UserWarning: pylab import has clobbered these variables: ['datetime'] 我嘗試過把%pylabe inline註解掉確實就可行了。 可是我有畫圖的需求阿,應該會有一拖拉庫的大大踩過這個坑才是。 懇請高手指導感恩。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 106.1.36.147 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1580211846.A.F01.html
yimean: 我自問自答一下好了,剛剛做了一個嘗試。 01/28 19:47
yimean: 把 from datetime import datetime 改成 01/28 19:47
yimean: from datetime import datetime as td就解了。哈哈。 01/28 19:48
TuCH: 應該是模組的名稱重複了 01/28 20:21