- import urllib.request
- import re
- content = urllib.request.urlopen("http://www.CodeSnippet.cn/")
- x = str(content.info())
- match = re.search('charset=(?P<charset>\\\\w*)', x, re.IGNORECASE)
- if match:
- temp = x.decode(match.group('charset'))
- #该片段来自于http://www.codesnippet.cn/detail/221020136574.html
来源: http://www.codesnippet.cn/detail/221020136574.html