我正在尝试使用urllib来处理简单请求,如下所示:
import urllib
my_url = "https://realpython.com/practice/aphrodite.html"
my_open = urllib.request.urlopen(my_url)
my_op = my_open.read().decode('utf-8')
print(my_op)
当我运行代码时,它返回我的数据库请求,该请求与urllib无关。而且,我收到了如下错误:
import urllib.request
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 88, in <module>
import http.client
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 71, in <module>
import email.parser
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/feedparser.py", line 27, in <module>
from email import message
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/message.py", line 16, in <module>
from email import utils
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/utils.py", line 29, in <module>
import socket
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py", line 52, in <module>
import os, sys, io, selectors
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/selectors.py", line 290, in <module>
class SelectSelector(_BaseSelectorImpl):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/selectors.py", line 317, in SelectSelector
_select = select.select
AttributeError: module 'select' has no attribute 'select'
我可以卸载并安装除urllib之外的任何库。请指导我这个错误。
答案 0 :(得分:0)
我创建了一个名为select.py的单独文件,但没有包含任何代码。在那之后,我没有收到任何错误。