if name == 'main':
target = 'http://gitbook.cn/'
req = requests.get(url=target)
print(req.text)
会报错
D:\Python\Python36\python.exe "C:/Users/zxy/PycharmProjects/Python Excerise/WebSpider/random.py"
Traceback (most recent call last):
File "C:/Users/zxy/PycharmProjects/Python Excerise/WebSpider/random.py", line 1, in
import requests
File "D:\Python\Python36\lib\site-packages\requests__init__.py", line 97, in
from . import utils
File "D:\Python\Python36\lib\site-packages\requests\utils.py", line 11, in
import cgi
File "D:\Python\Python36\lib\cgi.py", line 44, in
import tempfile
File "D:\Python\Python36\lib\tempfile.py", line 45, in
from random import Random as _Random
ImportError: cannot import name 'Random'
你好,从CSDN上看到你的爬虫教程觉得很有趣点了个赞就跟着照做,但出现了点问题望能回复 问题很简单,在pharm中 import requests
if name == 'main': target = 'http://gitbook.cn/' req = requests.get(url=target) print(req.text)
会报错
import requests
File "D:\Python\Python36\lib\site-packages\requests__init__.py", line 97, in
from . import utils
File "D:\Python\Python36\lib\site-packages\requests\utils.py", line 11, in
import cgi
File "D:\Python\Python36\lib\cgi.py", line 44, in
import tempfile
File "D:\Python\Python36\lib\tempfile.py", line 45, in
from random import Random as _Random
ImportError: cannot import name 'Random'
D:\Python\Python36\python.exe "C:/Users/zxy/PycharmProjects/Python Excerise/WebSpider/random.py" Traceback (most recent call last): File "C:/Users/zxy/PycharmProjects/Python Excerise/WebSpider/random.py", line 1, in
但是copy到cmd的python中运行没出现问题