python爬虫基础

Traceback (most recent call last):
  File "pyfiles/20210122/7964.py", line 3, in <module>
    print(resp.text)
UnicodeEncodeError: 'gbk' codec can't encode character '\ufffd' in position 0: illegal multibyte sequenceTraceback (most recent call last):
  File "pyfiles/20210122/7964.py", line 3, in <module>
    print(resp.text)
UnicodeEncodeError: 'gbk' codec can't encode character '\ufffd' in position 0: illegal multibyte sequence

在得到reponse响应后,加上一句:resp.encoding=resp.apparent_encoding,试一下看能否解决问题。