如何处理“OSError:cannotseek back after get firstbytes”在尝试将jpg文件提取到numpy数组时
回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在尝试将zip文件中的所有图像收集到numpy数组中。你知道吗</p>
<p>总是出错:
OSError:获取firstbytes后无法返回!你知道吗</p>
<pre><code>import urllib.request
import os
import zipfile
import scipy
import numpy as np
import pandas as pd
import glob
import imageio
from os.path import splitext
url = 'https://github.com/yoavram/Sign-Language/raw/master/Dataset.zip'
filename = '../data/sign-lang'
if not os.path.exists('../data'):
os.mkdir('../data')
if not os.path.exists(filename):
urllib.request.urlretrieve(url, filename)
zf = zipfile.ZipFile(filename)
for file in zf.namelist():
basename,extension = splitext(file)
if extension == '.jpg':
with zf.open(file) as img_file:
img = imageio.read(img_file)
</code></pre>
<p>救命啊?你知道吗</p>