错误1:TypeError: expected string or bytes-like object
错因:数据类型不匹配的错误 (期望的字符或者字节类型相反,英语不太好也8知道翻译的对不对)
解决方法:
将source强制转换为字符串
source=str(source)
错误2:UnicodeEncodeError: ‘gbk’ codec can’t encode character ‘\xa0’ in position
错因:使用Python将爬虫数据写入文件的时候出现的问题
解决方法:
在打开文件的那加一句 encoding=‘utf-8’
错误3:Error:‘xxx’ object is not callable
这种错误是在起变量名的时候不小心和系统中的重复了
比如我就起了一个变量名是 str
之后在用str进行强制类型转换的是时候就会报错
把变量名改掉就好啦
错误4:IndentationError: unindent does not match any outer indentation level
代码没有对齐