MCPcopy Create free account
hub / github.com/ZiniuLu/Python-100-Days / decode_page

Function decode_page

Day66-75/code/main.py:18–26  ·  view source on GitHub ↗
(page_bytes, charsets=('utf-8',))

Source from the content-addressed store, hash-verified

16
17
18def decode_page(page_bytes, charsets=('utf-8',)):
19 page_html = None
20 for charset in charsets:
21 try:
22 page_html = page_bytes.decode(charset)
23 break
24 except UnicodeDecodeError:
25 pass
26 return page_html
27
28
29class Retry(object):

Callers 1

fetchMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected