반응형
import attr
from typing import List
@attr.s(kw_only=True)
class ProductAddDto:
product_name: str = attr.ib(default="")
price: str = attr.ib(default="") # 상품가격
discount_price: str = attr.ib(default="") # 할인가격
category_id: str = attr.ib(default="") # 카테고리
detail_imgs: List[int] = attr.ib(default=[]) # 상세이미지
terms_imgs: List[str] = attr.ib(default=[]) # 약관이미지
if __name__ == "__main__":
productAddDto = ProductAddDto()
productAddDto.product_name = "상품명입니다."
productAddDto.category_id = "카테고리입니다."
productAddDto.detail_imgs = [
"dimg1.jpg",
"dimg2.png",
]
productAddDto.terms_imgs = [
"terms1.jpg",
"terms2.png",
]
ProductData 모델을 작성하는 코드이다.
getter setter를 별도로 설정하지 않아도 값 할당이 가능하다.
반응형
'프로그래밍 > python' 카테고리의 다른 글
| [반복문] 숫자를 역순으로 차례대로 출력하는 여러가지 방법 (0) | 2023.06.21 |
|---|---|
| 배열에 자료를 추가할 때, 배열의 가장 앞쪽에 추가하는 방법 (0) | 2023.06.20 |
| dict가 들어있는 list에서 특정 key를 지정해서 중복을 제거하는 코드 (0) | 2023.06.19 |
| 문자열을 휴대전화 번호 양식에 맞는지 검토하는 정규식 (0) | 2023.06.14 |
| 파이썬 셀레니움 로딩바 이미지 사라질때 까지 대기 (0) | 2023.06.13 |