问答详情
源自:7-5 Python的requests库

name 'requests' is not defined

已经在cmd pip install requests了 为什么还会报错 服务器也启动了

response = requests.get('https//:127.0.0.1:8000')
content = str(response.content, encoding='utf-8') # ==> 打印具体内容
content_list = content.split('\n') # 分行
for line in content_list:
    if 'href' in line and 'www' in line:
        print(line.strip())


Traceback (most recent call last):

  File "D:\python\work\main.py", line 2, in <module>

    response = requests.get('https//:127.0.0.1:8000')

NameError: name 'requests' is not defined


提问者:慕沐1354941 2022-05-09 21:35

个回答

  • qq_锦字_0
    2022-06-13 22:19:37

    先 import requests