Pycharm默認的Python是python2,但是如果代碼是python3寫的,就需要在pycharm里的project interpreter增加python3
注意,一定要找到Project Interpreter,這里是一定可以添加python3的路徑的。而不是在Run -> Edit configuration -> Python interpreter處添加。因為,如果你沒有在前者添加Python3, 后者是沒有這個選項的。當然,你在Project Interpreter處添加了python3之后,運行時可能還需要再改一下Edit configuration 里面的python interpreter, 把其選為python3
如何找到Project Interpreter,在 File -> default settings 里面。總之一定要找到Project Interpreter,才能正常添加。