ipython display html – not displaying html contents within try except

  ipython, python

So I’m trying to display the contents of a html file, but when I try to display it within a try except I don’t get anything. My print still shows the correct file/file path.

When I remove the try except it displays the file no problem. Why does this stop working once I put it in the try except?

import IPython

try :
  num= rec[46].iloc[0,0][4:]
  file= '/content/init'+num+'.html'
  print(file)

  IPython.display.HTML(filename=file)
except IndexError:
  print('select another!')

Source: Python Questions

LEAVE A COMMENT