Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
图像赢得';t在dash-python中加载_Python_Html_If Statement_Dashboard - Fatal编程技术网

图像赢得';t在dash-python中加载

图像赢得';t在dash-python中加载,python,html,if-statement,dashboard,Python,Html,If Statement,Dashboard,我在我的应用程序中创建了一个if语句来加载图像。如果情感为回调的==值,则在应用程序中加载图像 # load image for sentiment if overall_sentiment == "fear": image_filename = "fear.png" image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii') if overall_se

我在我的应用程序中创建了一个if语句来加载图像。如果情感为回调的==值,则在应用程序中加载图像

# load image for sentiment

if overall_sentiment == "fear":
  image_filename = "fear.png" 
  image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "sadness":
  image_filename = "sadness.png" 
  image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "anger":
  image_filename = "anger.png" 
  image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "disgust":
  image_filename = "disgust.png" 
  image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "enjoyment":
  image_filename = "enjoyment" 
  image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
我在我的应用程序中加载图像,如下所示:

    html.Img(
         html.H4("Overall sentiment"),
         id ="overall_sentiment",
         src='data:image/png;base64,{}'.format(image)
        )])
由于某些原因,图像将不会显示