Różnice
Różnice między wybraną wersją a wersją aktualną.
| Poprzednia rewizja po obu stronach Poprzednia wersja Nowa wersja | Poprzednia wersja | ||
| programowanie:python:start [2024/09/09 14:52] – sases | programowanie:python:start [2024/10/09 19:18] (aktualna) – sases | ||
|---|---|---|---|
| Linia 2: | Linia 2: | ||
| \\ | \\ | ||
| - | ===== HTTP ===== | + | ===== Środowisko wirtualne |
| - | [[https:// | + | * Utworzenie i uruchomienie |
| - | [[https://requests.readthedocs.io/ | + | < |
| - | \\ | + | python |
| - | + | source env/bin/activate | |
| - | === request === | + | </code> |
| - | < | + | |
| - | import requests | + | |
| - | + | ||
| - | html = requests.get(" | + | |
| - | print(html.text) | + | * Opuszczenie |
| + | < | ||
| + | deactivate | ||
| </ | </ | ||
| \\ | \\ | ||
| Linia 73: | Linia 71: | ||
| | ValueError | Raised when there is a wrong value in a specified data type | | | ValueError | Raised when there is a wrong value in a specified data type | | ||
| | ZeroDivisionError | Raised when the second operator in a division is zero | | | ZeroDivisionError | Raised when the second operator in a division is zero | | ||
| + | \\ | ||
| + | \\ | ||
| + | ===== MySQL ===== | ||
| + | Instalacja biblioteki: '' | ||
| + | Oficjalna dokumentacja: | ||
| + | Przykład: | ||
| + | <code python> | ||
| + | DB_CONFIG = { | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | } | ||
| + | |||
| + | db = mysql.connector.connect(**DB_CONFIG) | ||
| + | cursor = db.cursor(buffered=True) | ||
| + | |||
| + | cursor.execute(f" | ||
| + | result = cursor.fetchall() | ||
| + | result = cursor.fetchone() | ||
| + | cursor.close() | ||
| + | |||
| + | sql = " | ||
| + | val = (' | ||
| + | cursor.execute(sql, | ||
| + | db.commit() | ||
| + | added_id = cursor.lastrowid | ||
| + | |||
| + | db.close() | ||
| + | </ | ||
| \\ | \\ | ||
| \\ | \\ | ||
| ===== Obiektowo ===== | ===== Obiektowo ===== | ||
| - | W Python nie ma czegoś takiego jak prywatne/ | + | W Python nie ma czegoś takiego jak prywatne/ |
| <code python> | <code python> | ||