斜纹导致print()不显示

2024-05-19 00:21:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将Twill与Jupyter/Python结合使用。但是,如果我在导入斜纹布后使用Print()

from twill.commands import go, showforms, formclear, fv, submit, show

print("hi") 

它不会打印任何东西

这是正常的行为吗

这发生在google colan和jupyterLab上


Tags: fromimportgoshowjupytercommandssubmitprint
1条回答
网友
1楼 · 发布于 2024-05-19 00:21:53

您的模块可能有自己的sys模块,这会在导入时给Jupyter带来麻烦

试试这个:

from twill.commands import go, showforms, formclear, fv, submit, show
import sys

sys.stdout = stdout

print ('hi')

否则,我建议永远不要使用那些在线笔记本,我认为这些笔记本本质上是有限的,因为由于缺少与主Python相关的文档,不容易解决意外行为

相关问题 更多 >

    热门问题