import urllib.request
response = urllib.request.urlopen('http://www.baidu.com/')
print(response.read().decode('utf-8'))
当我运行上面代码为什么出现下面的情况:
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
----------------------------------------
Unhandled exception in user code execution server!'
Thread: SockThread
IDLE Client Address: ('127.0.0.1', 51801)
Request: <socket.socket fd=700, family=2, type=1, proto=0, laddr=('127.0.0.1', 52150), raddr=('127.0.0.1', 51801)>
Traceback (most recent call last):
File "C:\Python\Python311\Lib\socketserver.py", line 317, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python\Python311\Lib\socketserver.py", line 348, in process_request
self.finish_request(request, client_address)
File "C:\Python\Python311\Lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python\Python311\Lib\idlelib\rpc.py", line 514, in __init__
socketserver.BaseRequestHandler.__init__(self, sock, addr, svr)
File "C:\Python\Python311\Lib\socketserver.py", line 755, in __init__
self.handle()
File "C:\Python\Python311\Lib\idlelib\run.py", line 532, in handle
import pydoc # import must be done here to capture i/o binding
^^^^^^^^^^^^
File "C:\Python\Python311\Lib\pydoc.py", line 73, in <module>
import urllib.parse
File "C:\Python\Python311\urllib.py", line 1, in <module>
import urllib.request
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a package
*** Unrecoverable, server exiting!
Users should never see this message; it is likely transient.
If this recurs, report this with a copy of the message
and an explanation of how to make it repeat.
----------------------------------------