|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
while True:
url = "http://placekitten.com/%d/%d" % (num_w, num_l)
req = urr.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/61.0')
response = urr.urlopen(req)
html = response.read()
file_name = 'cat_miao_%s_%s.jpg' % (str(num_w), str(num_l))
with open(file_name, 'wb') as f:
f.write(html)
break
为什么报错
values[i] = one_value.encode('latin-1')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026' in position 30: ordinal not in range(256)
你的 …出了问题就在User-Agent的参数里面。有省略号导致报错
|
|