您可以在 Jupyter Notebook 的单元格中执行该操作:
%config IPCompleter.greedy=True
这给出了(在 ipython/jupyter 控制台中,但在笔记本中相同)
In [10]: my_list[0].<TAB>
my_list[0].a my_list[0].b
要永久拥有它,只需编辑您的文件ipython_config.py
,使其看起来像这样(注释行已经存在且未修改,大约在第 506-514 行):
#------------------------------------------------------------------------------
# Completer configuration
#------------------------------------------------------------------------------
# Activate greedy completion
#
# This will enable completion on elements of lists, results of function calls,
# etc., but can be unsafe because the code is actually evaluated on TAB.
c.Completer.greedy = True # <-- uncomment this line and set it to True
如果你没有ipython_config.py
,~/.ipython/profile_default/
你可以创建一个:
ipython profile create