【问题标题】:emacs python mode, python-send-buffer/string/region gives "Invalid Syntax" erroremacs python 模式,python-send-buffer/string/region 给出“无效语法”错误
【发布时间】:2011-11-04 06:14:26
【问题描述】:

我过去曾在不同的系统中成功使用过 python-mode 的 python-send-buffer(和类似的)。

我不明白为什么我会在这里出错。更糟糕的是,谷歌搜索没有帮助..
下面是我尝试通过 C-c C-r

将“from math import sqrt”发送到 Python 时的输出
>>> emacs.eexecfile("/var/folders/qy/qyS-532mGoWXHKmsdumelk+++TI/-Tmp-/py1850AbJ")
  File "/var/folders/qy/qyS-532mGoWXHKmsdumelk+++TI/-Tmp-/py1850AbJ", line 1
    from math import sqrt
^
SyntaxError: invalid syntax

我的系统是mac snowleopard和emacs 23.3.1,python 2.6.1

http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/125d72278d513bea?pli=1 谈论 ^M 。 我将建议的解决方案添加到我的 .emacs 但没有区别

 (add-to-list 'process-coding-system-alist 
      '("python" cp1251-unix . cp1251-unix)) 

【问题讨论】:

    标签: python macos emacs


    【解决方案1】:

    从错误消息来看,问题是您在行前插入了一些空格:抑扬符指向一个空格。缩进在 Python 中很重要,您不能以缩进的行开始脚本。

    【讨论】:

    • 这是为 windows 保存的文件,在 mac 中运行时出现问题。通过 C-x RET f 将编码更改为 undecided-unix。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多