代码出现AttributeError ‘NoneType’ object has no attribute“json”应该怎么解决

讨论数量: 4
Jason990420
gender_response = requests.get(gender_url)


What is the `requests` ?

import request                               # No matching distribution found for request
from django.contrib.sites import requests    # module 'django.contrib.sites.requests' has no attribute 'get'

or

import requests
1年前 评论
Canyon976 (楼主) 1年前
Jason990420
import requests

url = "https://api.genderize.io/?name=peter"
response = requests.get(url)
data = response.json()
print(data)
{'count': 1094417, 'name': 'peter', 'gender': 'male', 'probability': 1.0}
1年前 评论
Canyon976 (楼主) 1年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!