L.B*_*ira 1 python ipython jupyter-notebook
我正在尝试在 jupyter notebook 中显示 youtube 视频。但是当我将代码置于条件中时,它不会显示。但是,如果我删除 if 条件,它会起作用。
from IPython.display import HTML
a = input()
if a=="a":
  HTML('<iframe src="https://www.youtube.com/embed/S_f2qV2_U00?rel=0&controls=0&showinfo=0" width="560" height="315" frameborder="0" allowfullscreen></iframe>')
else:
  print('erro')
上面的代码不会显示视频的框。但是如果我像这个一样删除 if 条件,
from IPython.display import HTML
a = input()
HTML('<iframe src="https://www.youtube.com/embed/S_f2qV2_U00?    rel=0&controls=0&showinfo=0" width="560" height="315"  frameborder="0" allowfullscreen></iframe>')
它会工作得很好。
小智 14
试试这个技巧,让我知道:
from IPython.display import YouTubeVideo
YouTubeVideo('WSbgixdC9g8', width=800, height=300)
| 归档时间: | 
 | 
| 查看次数: | 4796 次 | 
| 最近记录: |