在VOC格式的SSD训练数据标签中添加图片宽高等信息,并进行坐标越界检查。
# coding: utf-8
import os
from xml.etree.ElementTree import ElementTree,Element
from PIL import Image
def read_xml(in_path):
'''''读取并解析xml文件
in_path: xml路径
return: ElementTree'''
tree = Ele
python按行读取文件并找出其中指定字符串
#coding=utf-8
import os, time, sys, re
#reload(sys)
#sys.setdefaultencoding(utf8) # 不设置,否则编码方式不对应,无法找出字符串
file = open(path)
sum=0
for line in file.readlines():
#line = line.strip(\n)
key = 解析渲染
if key in line:
如下所示:
from bs4 import BeautifulSoup
path = './web/new_index.html'
with open(path, 'r') as f:
Soup = BeautifulSoup(f.read(), 'lxml')
titles = Soup.select('ul > li > div.article-info > h3 > a')
for title in titles:
print(title.text)
输出: