【问题标题】:Shows error : "not defined"while using magic function in jupyter显示错误:在 jupyter 中使用魔术函数时“未定义”
【发布时间】:2016-07-14 12:39:44
【问题描述】:
d = 8.6
print '%1.0f' %(d)

显示错误'd' is not defined

我正在使用 jupyter 笔记本。

使用代码

print '%1.0f' %(8.6)

给出正确的值。但是,它不能识别 'd' 对象

【问题讨论】:

  • 它对我来说很完美。你确定你没有打错什么吗?
  • 我也无法使用给定的代码示例重现此问题。我在自己的行上输入%(d) 时得到ERROR: Line magic function `%(d)` not found.

标签: python-2.7 jupyter-notebook magic-function


【解决方案1】:

只有一个可能的原因,将赋值和变量 d 的使用放在同一行会出错。

d = 8.6 
print '%1.0f' %(d)

print '%1.0f' %(d)

通常在 jupyter notebook 上为我工作!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-18
    • 2021-10-27
    • 2013-08-13
    • 2017-05-23
    • 1970-01-01
    • 2019-10-02
    • 2019-03-23
    • 1970-01-01
    相关资源
    最近更新 更多