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