問題描述
如何從控制台中導入的文件中訪問變量的內容? (How do I access the contents of a variable from a file imported in a console?)
I have a file, light.py that I'm trying to debug. In the python console, I type "import light" and it runs the program. But I want to check the contents of some variables by typing the variables. How do I do that?
‑‑‑‑‑
參考解法
方法 1:
You have a variable named test
in your file light.py
import light
print light.test
If you want to test DURING the running of your program you need to use pdb to debug the execution
(by Jonathan、Jakob Bowyer)