Display SVG in IPython notebook from a function

前端 未结 2 1085
情歌与酒
情歌与酒 2021-01-31 17:30

In IPython notebook, the following code displays the SVG below the cell:

from IPython.display import SVG
SVG(url=\'http://upload.wikimedia.org/wikipedia/en/a/a4/         


        
2条回答
  •  情书的邮戳
    2021-01-31 18:31

    Add return to your function :

    from IPython.display import SVG
    def show_svg():
        return SVG(url='http://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg')
    

    Then call your functions as the last line in cell:

    show_svg()
    

提交回复
热议问题