【问题标题】:Newlines in Function Definition for iPython TerminaliPython 终端的函数定义中的换行符
【发布时间】:2014-01-30 19:54:45
【问题描述】:

使用 %paste,iPython 将我的函数定义中的换行符作为函数的结尾。当我从别人的机器上编码时,这不是问题。我浏览了配置文档和其他网站;不走运。

def get_sheet(filepath, sheet_name):

    book = open_workbook(filepath)
    for name in book.sheet_names():
        if sheet_name in name.lower():
            sheet_name = name

    sheet = book.sheet_by_name(sheet_name)

    return sheet

SyntaxError: 'return' outside function

非常感谢 =)

【问题讨论】:

  • 你有什么版本的 IPython?这对我有用。

标签: python ipython ipython-magic python-config


【解决方案1】:

使用%cpaste,需要两个破折号才能退出模式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-23
    • 2015-05-03
    • 2015-03-02
    • 2012-04-17
    • 2014-12-14
    • 1970-01-01
    • 2015-03-04
    相关资源
    最近更新 更多