Вступ до API в Python
Chris Ramakers
Engineering Manager
http://350.5th-ave.com/unit/243

# Додайте параметри запиту до рядка URL
response = requests.get('http://350.5th-ave.com/unit/243?floor=77&elevator=True')
print(response.url)
http://350.5th-ave.com/unit/243?floor=77&elevator=True
params, щоб додати параметри запиту# Створіть словник
query_params = {'floor': 77, 'elevator': True}
# Передайте словник через аргумент `params`
response = requests.get('http://350.5th-ave.com/unit/243', params=query_params)
print(response.url)
http://350.5th-ave.com/unit/243?floor=77&elevator=True
http://350.5th-ave.com/unit/243| Verb | Дія | Опис |
|---|---|---|
| GET | Read | Перевірити вміст поштової скриньки |
| POST | Create | Покласти нову посилку в скриньку |
| PUT | Update | Замінити всі посилки новою |
| DELETE | Delete | Забрати всі посилки зі скриньки |
# GET = Отримати ресурс response = requests.get('http://350.5th-ave.com/unit/243')# POST = Створити ресурс response = requests.post('http://350.5th-ave.com/unit/243', data={"key": "value"}) # PUT = Оновити наявний ресурс response = requests.put('http://350.5th-ave.com/unit/243', data={"key": "value"})# DELETE = Видалити ресурс response = requests.delete('http://350.5th-ave.com/unit/243')
requestsdata, щоб передати дані в запит POST або PUT.Вступ до API в Python