1.生成相关的html文件
python
import json
import os
import calc
import requests
import numpy as np
with open('picture', 'r',encoding='utf-8') as f:
lines = f.readlines()
html = '<html>\n<html lang="zh">\n<head>\n<meta charset="UTF-8">\n<title>图片展示</title>\n</head>\n<body>\n'
for line in lines:
line_vec = line.strip().split("\t")
html += '<div>\n'
if len(line_vec)>2:
for i in range(2,len(line_vec)):
html += '<img src="'+line_vec[i]+'" width="400">\n'
html += '<p>query is: {'+line_vec[0]+'}</p>\n'
html += '<p>tags are: {'+line_vec[1]+'}</p>\n'
html += '</div>\n'
html += '</body>\n</html>'
# 写入HTML文件
with open('result.html', 'w') as f:
f.write(html)
2.终端执行
bash
python3 -m http.server 8080
3.浏览器访问ip+端口号进行查看(改成自己当前机器的ip)
bash
http://127.0.0.1:8080/result.html