在刚开始学习python准备学习爬虫时在使用pycharm编译出现了错误
这是源码:
#!usr/bin/python import urllib.request url = "http://www.baidu.com" get = urllib.request.urlopen(url).read() print(get)
这个本来就很简单但是出现了以下错误:
C:\Programming\Python\WeChat\venv\Scripts\python.exe C:/Programming/Python/learning/spiderlearning.py
Traceback (most recent call last):
File "C:/Programming/Python/learning/spiderlearning.py", line 2, in <module>
import urllib.request
File "C:\Users\16689\AppData\Local\Programs\Python\Python36\Lib\urllib\request.py", line 88, in <module>
import http.client
ModuleNotFoundError: No module named 'http.client'; 'http' is not a package
我觉得莫名其妙,最后才发现我在统一个文件夹下有一个http.py的文件,但是奇怪的是我运行http.py是可以成功运行的
这里应该是关键字敏感导致的错误。删除这个文件、修改文件名后就可以正常运行了!