Skip to content

Instantly share code, notes, and snippets.

@shau-lok
Created April 29, 2018 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shau-lok/407a014de199ba2565482bcac1e9332d to your computer and use it in GitHub Desktop.
Save shau-lok/407a014de199ba2565482bcac1e9332d to your computer and use it in GitHub Desktop.
解决requests 返回的内容编码 (iso-8859-1) 问题
# Refers: https://github.com/requests/requests/issues/1604
# 方法1:
r = requests.get('http://irresponsible-server/')
r.encoding = 'utf-8'
# 方法2:
r = requests.get('http://irresponsible-server/')
r.encoding = r.apparent_encoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment