In eclipse, there is this handy shorthand CTRL+SHIFT+o which will auto include the import (include) statements which are needed based on the Class or module being used.
Have you found any such plugin for vim or emacs?
解决方案
Ropemacs has rope-auto-import, so that if you write
rmtree
and execute M-x rope-auto-import,
from shutil import rmtree
is inserted at the top of the file. You might want to avoid this though, because importing functions from modules may not be a very wise idea.
See this SO post for information on setting up ropemacs.
The README (e.g. /usr/share/doc/python-ropemacs/README.txt.gz) that comes with ropemacs also has useful information for setting up the cache used by the ropemacs-auto-import command.