如何在Jupyter笔记本中不包裹而打印很长的字符串?

时间:2018-12-13 11:51:01

标签: python jupyter-notebook jupyter

示例:

print("Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo."

输出:

Sed ut perspiciatis unde omnis iste natus error sit voluptatem 
accusantium doloremque laudantium, totam rem aperiam, eaque 
ipsa quae ab illo inventore veritatis et quasi architecto 
beatae vitae dicta sunt explicabo.

所需的输出:

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.

3 个答案:

答案 0 :(得分:0)

键入您的cmd提示符或等效项:stop-application-if-exists: cmd: - run - name: cd /opt/TEST/{{pillar['instance-id']}}/Application/tomcat/bin && ./shutdown.sh && process_id=$(ps -aef|grep catalina|grep -v grep|grep "/opt/TEST/{{pillar['instance-id']}}/Application/tomcat/"|awk '{print $2}') && if [ ! -z "$process_id" ];then echo "$process_id"|xargs kill -9;fi - cwd: /opt/TEST/ - unless: "[ ! -e /opt/TEST/{{pillar['instance-id']}}/Application/tomcat/bin/shutdown.sh ]" - runas: {{pillar['user']}} download-installer: cmd: - run - name: " mkdir -p /u01/Release/build_{{ pillar['id'] }} && wget {{ pillar['zipurl'] }} -P /u01/Release/build_{{ pillar['id'] }} && unzip -q /u01/Release/build_{{ pillar['id'] }}/*.zip -d /u01/Release/build_{{ pillar['id'] }} && wget {{ pillar['xmlurl'] }} -P /u01/Release/build_{{ pillar['id'] }}/{{ pillar['release-ver'] }} " - runas: {{pillar['user']}} install-application: cmd: - run - name: "java -DHFShowAllPanels=true -jar test-installer-2.0.jar auto-deploy.xml" - cwd: /u01/Release/build_{{ pillar['id'] }}/{{ pillar['release-ver'] }} - require: - download-installer - runas: {{pillar['user']}} start-application: cmd: - run - name: "./startup.sh" - cwd: /opt/TEST/{{pillar['instance-id']}}/Application/tomcat/bin - require: - install-application - runas: {{pillar['user']}} 以获取Jupyter设置位置。 在设置位置jupyter --config-dir内创建一个文件夹nbconfig。在内部,使用以下文件创建文件/.jupyter

notebook.json

重新启动jupyter并重新加载,然后尝试

答案 1 :(得分:0)

答案 2 :(得分:0)

您需要应用了一些CSS的HTML输出。这是您可以尝试的代码:

type FuncResult struct {
    Resultid      int
    Resultmessage string
}
...
fResult := FuncResult{}
err := s.db.Raw("SELECT * from  activate(?)", token).Scan(&fResult).Error

现在,您将import IPython.display as dp long_txt = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo." outp = dp.HTML("<style>.nowrap{white-space:nowrap;}</style><span class='nowrap'>" +long_txt+ "</span>") 作为HTML对象。您可以渲染它并获得长的单行文本。

outp

outp 将是:

output

希望有帮助。