令人驚訝的是,我發現我無法將自定義python變量導入到ipython NOTEBOOK中。但是,它可以被導入到ipython shell。如何將自定義python變量導入python NOTEBOOK?
在config.py
,A = 100
。
在蟒蛇NOTEBOOK,
import config
config.A
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-54-a03322ffb792> in <module>()
----> 1 config.LAYER
AttributeError: 'module' object has no attribute 'A'
在Python Shell,
>>> config.A
'100'
不介意'圖層'。我只是忘了把它轉換成其他一些隨機數字,比如'A'。 –
感謝您的確認。這對我來說就夠了。 –