Python study----------常见错误:AttributeError: partially initialized module 'requests' has no attribute 'get' (most likely due to a circular import)
>>> import requests
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import requests
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\requests.py", line 4, in <module>
r=requests.get(link,headers=headers)
AttributeError: partially initialized module 'requests' has no attribute 'get' (most likely due to a circular import)
>>>
AttributeError: partially initialized module 'requests' has no attribute 'get' (most likely due to a circular import)
AttributeError:部分初始化的模块“ requests”没有属性“ get”(很可能是由于循环导入)
本来打算在学习下requests库,结果打开出现错误,瞬间懵逼了,赶紧查资料,出现这种错误的原因不是代码写错,而是,该代码文本的命名为requests.py,造成冲突。
python中明文规定不能以python的关键词来命名文件。
所以,以后切记不能以类名,包名来命名。
将此文件删除后,requests导入正常
余生山海远阔,愿你随心所向,随梦所往,随爱所去