1. 程式人生 > >AttributeError: 'module' object has no attribute 'urlopen報錯解決辦法

AttributeError: 'module' object has no attribute 'urlopen報錯解決辦法

AttributeError: ‘module’ object has no attribute 'urlopen
在python3中此處的urllib都應該改成urllib.request

python NameError: name ‘raw_input’ is not defined
在python3中用input替換了raw_input

TypeError: can’t use a string pattern on a bytes-like object
在python3中應在正則表示式前應新增html = html.decode(‘utf-8’)

以上是幾個用python初學爬蟲時因python3和python2的區別造成的報錯。