简体   繁体   English

如何确定Jupyter笔记本电池的输出?

[英]How to determine the output of jupyter notebook cells?

Cell1 outputs only 222, but Cell2 outputs 111 and 222. What's the difference? Cell1仅输出222,而Cell2输出111和222。有什么区别?

Cell1 单元格1

    In [1]: 111
            222
    Out[1]: 222

Cell2 单元格2

    In [2]: print(111)
            print(222)
    Out[2]: 111
            222

IPython prints the value of the last expression in a cell, except if the value is none or if the expression is followed by a semicolon (;). IPython打印单元格中最后一个表达式的值,除非该值不为null或该表达式后跟一个分号(;)。

222 is the last expression in cell1, so it is printed. 222是单元格1中的最后一个表达式,因此将其打印出来。

The second cell prints two values to stdout; 第二个单元格将两个值打印到stdout; print() returns None , which IPython refrains from printing. print()返回None ,IPython拒绝了它的打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM