Python 3中response.text.decode('utf-8') 报错 AttributeError: 'str' object has no attribute 'decode'
在Python 3中,字符串对象默认情况下已经是Unicode编码的,因此没有decode()方法。所以你可以直接使用response.text来获取HTML的内容。
如果你想将HTML内容解码为其他编码格式,可以使用str.encode()方法将字符串编码为指定的编码格式。例如:
html = response.text.encode('utf-8')
原文地址: https://www.cveoy.top/t/topic/khP9 著作权归作者所有。请勿转载和采集!