我正在尝试从会议办公室的网站上抓取天气数据,但是我一直遇到错误。
这是我到目前为止尝试过的
stats = ['Tmax', 'Tmin', 'Rainfall']
regions = ['England', 'Wales', 'Scotland']
base_url = r'https://www.metoffice.gov.uk/pub/data/weather/uk/climate/datasets/{}/date/{}.txt'
dframes = []
for r in regions:
for s in stats:
url = base_url.format(s,r)
df = pd.read_table(requests.get(url).content)
dframes.append(df)
我遇到一个错误:
"OSError: Expected file path name or file-like object, got <class 'bytes'> type"
答案 0 :(得分:6)
您必须在流中使用这些字节,例如 // check for rows
<?php if( have_rows('item_list_details') ): ?>
<ul class="admin">
<?php
// loop through rows
while( have_rows('item_list_details') ): the_row()
// display each item as a list
?>
<li class='new'>
<div class='itemTitle'>
<?php the_sub_field('link_name'); ?>
</div>
<div class="memberListDate">
<?php the_sub_field('date'); ?>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
:
io.BytesIO