【发布时间】:2016-06-07 16:30:41
【问题描述】:
我切换到 Emacs。我在 Emacs 中使用 Elpy 作为 IDE。我的设置是并排的窗口,左侧是一个缓冲区(脚本),我在其中编写/编辑代码,然后使用Ctrl-Enter 将其发送到右侧的 IPython shell。当我输入函数时:
import numpy as np
import pandas as pd
data = pd.read_csv('spx_index.csv')
def convert(x):
return x.ix[:, 1:].set_index(x.ix[:, 0])
进入脚本(4 个空格缩进)并按两次Ctrl-Enter 我得到:
>>> ... File "<stdin>", line 2
return x.ix[:, 1:].set_index(x.ix[:, 0])
^
IndentationError: expected an indented block
但是,当我复制函数并将其直接粘贴到 IPython shell 中时:
>>> def convert(x):
return x.ix[:, 1:].set_index(x.ix[:, 0])
... ...
>>>
它工作并且功能被保存。
让函数直接从脚本运行到 shell 将是理想的。我无法想象必须将每个函数复制并粘贴到 shell 中。
【问题讨论】:
-
C-c C-c工作正常吗? -
是的。这工作正常。当我这样做时,该功能被保存。这肯定解决了我的问题。有没有办法逐行进行?
标签: python function shell emacs elpy