반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 파이썬 가상환경 설치
- 파이썬 네이버 로그인
- 파이썬 환경설정
- Selenium 셀렉터잡기
- 가상환경설치
- 왕초보 파이썬 실행
- 네이버부동산크롤링
- pycdas.exe
- 커머스API
- uipath 입문
- pywinauto 윈도우
- selenium
- pywinauto
- pywinauto 윈도우제어
- 네이버매물크롤링
- 날짜 정규식
- Uipath 설치방법
- pycdc.exe
- 네이버커머스API
- Element is not clickable at point
- vscode venv 설치
- Python
- 네이버 로그인 하기
- 파이썬 가상환경 설치방법
- 네이버 로그인 영수증 해결
- 파이썬네이버부동산
- 네이버 로그인 캡챠해결
- Uipath 기초
- UiPath
- venv 설치
Archives
- Today
- Total
콘솔워크
dataclass 대신 attr을 활용한 데이터 객체 클래스 만들기 본문
반응형
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 |