jupyter-notebook输出for循环没有显示

时间:2016-03-01 15:01:43

标签: jupyter-notebook hachoir-parser

当我使用python2.7运行我的Jupyter-notebook并尝试使用for循环打印项目(列表)时,导入以下软件包后不会输出print语句:

     public function actionCreate()
    {
        $model = new Answer();
        var_dump(Yii::$app->request->post());`enter code here`
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            $model->answer_by= \Yii::$app->user->getId();
            $name = $model->answer_attachment;
            var_dump($name);
            $model->answer_attachment = UploadedFile::getInstanceByName('btn.jpg');
            var_dump($model->answer_attachment);
             $time=time();
            if(!empty($model->answer_attachment)){
                $model->answer_attachment->saveAs('images/answer/'.$time.'.'.$model->answer_attachment->extension);
                $model->answer_attachment='images/answer/'.$time.'.'.$model->answer_attachment->extension;
            }
            $model->answer_timestamp=$time;
            //$model->save();
            //return $this->redirect(['view', 'id' => $model->answer_id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }

示例代码:

import sys
import os
from hachoir_core.cmd_line import unicodeFilename
from hachoir_metadata import extractMetadata
from hachoir_parser import createParser
from hachoir_core.i18n import getTerminalCharset
from hachoir_core.tools import makePrintable
import pandas as pd

输出为空白。

当我在导入之前使用完全相同的代码时,它会显示。

看起来hachoir导入是个问题,每当我导入包含它的任何东西时,输出就会停止显示。

1 个答案:

答案 0 :(得分:1)

重新发布答案:hachoir_metadata模块似乎对stdout做了一些奇怪的事情,它破坏了IPython:Bug report

如该链接所述,您需要在导入hachoir_metadata之前添加以下代码

from hachoir_core import config
config.unicode_stdout = False