Pydantic? Python? ??? ?? ? ?? ?? ????????. Python ?? ??? ???? ???? ???? ???? ?? ???? ??? ???? ????? ??? ??? ???? ????? ?????. Python? ??? ???? ??? ?? ??? ?????? Pydantic? ??? ???? ?? ???? ?? ???? ??? Python ???? ???? ???? ???? ???/????? ? ?? ????. ?? ??? ???????:
??? ??
Python? ?? ??? ???? ???? ?? ?? ???? ???? ?????.
from pydantic import BaseModel, ValidationError class User(BaseModel): id: int name: str email: str # Valid input user = User(id=1, name="John Doe", email="john@example.com") print(user) # Invalid input try: user = User(id="not-an-integer", name="Jane", email="jane@example.com") except ValidationError as err: print(err)
??? ??? ???? ?? ??? pydantic.BaseModel? ?????!
?? ??
Pydantic? ??? ???? ??? ??? ??? ??? ??? ? ?? ??? ??? ?????. ?? @validate_call ?????? ???? ???? ?? ?? ? ?? ?? ?? ??? ??? ??? ??? ??? ? ????. ??? ?? ?? ?? ??? ?? ??? ???? ??? ValidationError? ?????.
from pydantic import validate_call @validate_call def greet(name: str, age: int) -> str: return f"Hello {name}, you are {age} years old." # Valid input print(greet("Alice", 30)) # Output: Hello Alice, you are 30 years old. # Invalid input try: greet("Bob", "not-a-number") except Exception as e: print(e)
@validate_call?? verify_return ???? ??????? Pydantic? ??? ?? ?? ??? ?? ??? ?? ?? ?????. ??? ?? ??? ???? ?? ???? ???? ???.
from pydantic import validate_call @validate_call(validate_return=True) def calculate_square(number: int) -> int: return number ** 2 # Correct return type # Valid input and return print(calculate_square(4)) # Output: 16 # Invalid return value @validate_call(validate_return=True) def broken_square(number: int) -> int: return str(number ** 2) # Incorrect return type try: broken_square(4) except Exception as e: print(e)
??
Pydantic? JSON ???? ??? ??? ?? ??? ?? ??? ?? ??? ? ????.
from pydantic import BaseModel from typing import List class Item(BaseModel): name: str price: float class Order(BaseModel): items: List[Item] total: float # JSON-like data data = { "items": [ {"name": "Apple", "price": 1.2}, {"name": "Banana", "price": 0.8} ], "total": 2.0 } order = Order(**data) print(order) # items=[Item(name='Apple', price=1.2), Item(name='Banana', price=0.8)] total=2.0
??? ? ????
Pydantic ??? JSON?? ???? ????? ?? ???? ? ????.
from pydantic import BaseModel class User(BaseModel): id: int name: str email: str # Create a model instance user = User(id=1, name="Alice", email="alice@example.com") # Serialize to dictionary and JSON user_dict = user.model_dump() user_json = user.model_dump(mode='json') print("Dictionary:", user_dict) print("JSON:", user_json) # Deserialize back to the model new_user = User.model_validate(user_json) print("Parsed User:", new_user)
??? ??
??? ??? ??? ??? ????. ?? ?? ?? int, bool ? datetime ??? id, Due_date ? ???? ??? ???? ??? ???? ?? ??? ??? ? ????.
- ID? ?? ???
- ISO-8601, UTC ?? ?? ?? ??? ???(??_??)
- '?'/'???', '??'/'??', '?'/'??', 1/0 ? ????
from sensei import APIModel from datetime import datetime class Task(APIModel): id: int due_date: datetime priority: bool task = Task(due_date='2024-10-15T15:30:00',> <p>The result will be<br> </p> <pre class="brush:php;toolbar:false">Task(id=1, due_date=datetime.datetime(2024, 10, 15, 15, 30), priority=True)
??? ??
???? ???? ??? ??? ?? ?? ??? ??? ?? ????. ?? ?? ???? ?? ?? ??? ???? ?? ??? ? ?? ?? ??? ??? ?? ??? ??? ? ????. ??? ???? field_validator ????? ?? Field ??? ?? ?????. ?? ??? ?? ??? field_validator? ???? ?? ??? ? ??? ???? ???? ????? '*'? ???? ?? ??? ??? ???? ??? ? ????.
import Any ???? pydantic import Field, field_validator, EmailStr, BaseModel?? ??? ???(BaseModel): ???: ?? ??? ??: str = Field(pattern=r'^w $') ???: EmailStr age: int = Field(18, ge=14) is_active: ?? = ? ??: ??[str] # ?? ?? ?? '??' ???? ??? ???? ?????. @field_validator('??', ??='??') def _validate_roles(cls, ?: ??): return value.split(',') if isinstance(value, str) else value user = ???(id=1, ??? ??='john', ???='john@example.com', ??='??,??') ??(???) #> <h2> ?? ?? ???? </h2> <p>Pydantic? ???? ?? ???? ????? ?? ????. ? ? ??? ??? ???????.</p> <h3> FastAPI </h3> <p>Pydantic? ?? ?? ?? ?? ?? ? ??? Python?? API? ???? ?? ?? ? ?????? FastAPI???. FastAPI? ?? ?? ??, ?? ???? ? ?? ???? ?? Pydantic ??? ????? ?????.</p>
- ??: https://github.com/fastapi/fastapi
- ??: https://fastapi.tiangolo.com
???
FastAPI? API ????? ??? ?? Sensei? ??? API? ??? ?? ????? ???????. Sensei? ???? API ?????? ???? ?? ??? ??? ?? ????? ??? ???? ??? ?????.
- ??: https://github.com/CrocoFactory/sensei
- ??: https://sensei.crocofactory.dev
SQLModel ? Typer
SQLModel? Typer? FastAPI? ???? Sebastián Ramírez? ??? ? ?? ????? ???????.
SQLModel? Python ???????? ?????? ?? ??? ?????? ??? ????????. SQLAlchemy ? Pydantic? ???? ??? SQLModel? ORM? ??? ??? ??? ?? ? ???? ???? ?????.
- ??: https://github.com/fastapi/sqlmodel
- ??: https://sqlmodel.tiangolo.com
Typer? Python? ???? ??? ?????(CLI) ??????? ??? ?? ????????. Python? ?? ??? ???? ????? ??? CLI ??? ??? ???? ???? ?????? ????? ??????.
- ??: https://github.com/fastapi/typer
- ??: https://typer.tiangolo.com
? ??? Pydantic: ?? ??? ?! ?? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











? ?? ???? ?????? ???????. Python ? ???? ???? ????? XSS, SQL ??, CSRF ? ?? ??? ??? ?????. XSS? ?? ??? ??? ???? ???? ???? ?? ??? HTML? ????? CSP ??? ???????. SQL ??? ???? ?? ?? ??? ? ?? ?? ORM ??? ?? ? ??? ??? ??????. CSRF? ????? CSRFTToken ????? ??????? ??? ??? ? ? ???????. ?? ??? ???? ??? ???? ?? ??? ??? ?? ??? ???? ? ???????. ??? ??? ??? ??? ???? ??? ????? ?? ? ??? ??? ??????? ???? ?????.

Python? Unittest ? Pytest? ??? ? ???? ??, ?? ? ??? ????? ? ?? ?? ???? ??? ??? ?????. 1. ??? ??? ?? ??? ???? ??? ??? ??? ?????. UnitTest? ??? ??? ???? ???? Test \ _? ???? ???? ?????. Pytest? ? ?????. Test \ _?? ???? ?? ? ??????. 2. ??? ?? ?? ? ?? ? ??? ??? ????. UnitTest? Assertequal, AssertTrue ? ?? ??? ???? ?? Pytest? ??? Assert ?? ???? ?? ?? ??? ???? ?????. 3. ?? ??? ?? ? ?? ????? ????? ????.

Python? ?? ?? ??? ?? ? ???? ??????. ?? ??? ?? (? : ?? ?? ??)? ?? ?? ??? ???? ?? ??? ?? ??? ??? ? ????. ?? ??, ? ??? ?? ?? ??? ???? ??? ?? ?? ??? ?? ? ??? ???? ?? ??? ??? ??????. ? ???? ?? ??? ??? ????. 1. ?? ?? ?? ??? ?? ??? ??; 2. ?? ?? ??? ?? ??? ??? ?? ???? ???? ??????. 3. ??? ??? ???? ????? ???. 4. ???? ?? ? ???? ????? ????. ??? ??? ?? ?? ??? ???? ???? ???? my_list = [] ?? my_list = none? ???? ?? ?? ?? ??? ? ??? ??? ???? ??? ????.

?? ??? Python ?? ????? ????? ???, ?? ? ?? ?????? ???????. ?? Gunicorn ?? UWSGI? ???? ?? ??? ???? ?? ??? ?????. ??, ??? ??????? ?? ????? Nginx? ??????. ??, ??? ????? ?? CPU ?? ?? ?? ???? ?? ?????. ??, ?? ??? ???? ???? ???? ??? ???? ???? ?????. ???, ??? ??? ?????, ???? ???? ????, ?? ????? ???? ?? ? ?? ??? ???????. ???, ?? ????? ???? ??? ??? ?? HTTPS? ???? ??? ???? ?? ??? ?????. ?????, ?? ??? ??? ?? CI/CD ??? ?? ?? ??? ?????.

Python? ???? ??? ????? ?? ?? ? ???? ? ?????. ??? ? ???? ????? ???? ????? ???? ?????. 1. ?? API ? ?? ???? (? : HTTP, REST, GRPC)? ???? Python? Flask ? Fastapi? ?? ??? ??? ?? API? ???? ?? ?? HTTPX? ???? ?? ?? ???? ?????. 2. ??? ??? (Kafka, Rabbitmq, Redis)? ???? ??? ??? ???? Python Services? ?? ?? ???? ?? ? ???? ???? ??? ?? ?? ?, ?? ? ? ?? ??? ?? ? ? ????. 3. ??? ???? ?? C/C? ?? ?? ?? ??? (? : Jython)? ?? ?? ??

pythonisidealfordataanalysisduetonumpyandpandas.1) numpyexcelsatnumericalcomputationsfast, multi-dimensionalArraysandectorizedOferationsLikenp.sqrt ()

??? ?? ???? ????? ????? __iter_ ? __next__ ???? ???????. ① __iter__ ???? ??? ? ?? ??? ???? ??? ?? ?? ??? ?????. ② __next__ ???? ? ??? ?? ????, ?? ??? ??? ????, ? ?? ??? ??? stopiteration ??? ??????. status ??? ???? ??????? ?? ??? ??? ?? ?? ??? ???????. pile ?? ?? ???? ?? ??? ?? ? ??? ?? ? ??? ?????? ?????. simple ??? ??? ?? ?? ??? ?? ???? ???? ?? ??? ? ??? ?? ????? ???? ??? ??? ???????.

Python? ??, ?? ? ?? ??? ??? ??? ?? ?? ??? ? ?? ???? ??????. ??? ?? ?? ??? ?? ?? ??? ??? ?? ?? ?? ???? ???? ? ?? ? ?? ??? ????? ? ?????. 1. [x2forxinRange (10)]? ?? ?? ??? ?? ???? ?? ?? ? ? ????. 2. {x : x2forxinrange (5)}? ?? ?? ???? ? ? ??? ???? ?????. 3. [xforxinnumbersifx%2 == 0]? ?? ??? ???? ??? ????? ????? ????. 4. ??? ??? ?? ?? ?? ??? ?? 3 ? ???? ???? ?? ?? ?? ? ???. ??? ?? ?? ???? ???? ??? ?? ?? ??? ??? ??????. ??? ???? ??? ?? ? ? ????
