jupyter notebook | 您所在的位置:网站首页 › jupyter没有输出直接下一行 › jupyter notebook |
jupyter notebook | 不用print即可输出多个变量
缘由解决方法单个文件整个notebook
缘由
有时候在jupyter notebook上想监测某些变量的时候希望在一个cell里输出多个,但是又不懒得不断print,但是这样只会输出最后一个的值,比如: a,b = 1,2 a b 2 解决方法 单个文件如果希望不需要print即可同时输出a b的值,在jupyter notebook开头运行这两行代码: from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all"然后测试: a,b = 1,2 a b 1 2P.S. 如果不喜欢这个配置,改回来 InteractiveShell.ast_node_interactivity = "last"更多选项参见官网 P.S.S. 这样又有个问题,如果我只是想放那里但是不想它输出,这个时候只需要在代码后面加个;即可~ 整个notebook如果要为Jupyter所有实例设置这个的话,首先找到jupyter notebook安装目录,使用cmd运行jupyter notebook --generate-config即可,如图。 接下来,在路径~/.ipython/profile_default/下创建ipython_config.py文件即可: c = get_config() # Run all nodes interactively c.InteractiveShell.ast_node_interactivity = "all" |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |