<Beginner Question> Python console cannot run updated function from script

已回答

I just started to learn Python so I thank all your patience with me in advance!

So I created a simple function a() in script called Sample.py and imported in the Python console. Then I called the function a() and I get the expected answer 1. 

However, after I let the a() function print 2 instead of 1 and imported the script again. The a() function still prints out 1. In order to make it right, I have to restart PyCharm. Could anyone please answer this silly question? It annoys me so much :( 

 

0

Hi! You need to re-import your module (load it to interpreter again), just print: reload(Sample).

0

请先登录再写评论。