hehehe

    programming/python

    @(데코레이터)

    함수를 수정하지 않고 유연하게 함수에 특정 동작을 추가하거나 작동 방식을 바꿀 수 있다. decorate() 함수는 함수를 인자로 받고, 내부 wrapper() 함수는 decorate() 함수의 인자로 넘어온 함수를 호출한다. hello() 함수를 decorate() 함수의 인자로 넘긴 후, hello2 변수에 할당하면 "hello" 출력 전에 before, 후에 "after"이 출력되는 것을 볼 수 있다. def hello(): print("hello") def decorate(func): def wrapper(): print("before") func() print("after") return wrapper hello2=decorate(hello) hello2() @ 기호와 함께 함수 헤더 위에 데코..

    programming/python 2023.01.01
    이전
    1 2 3
    다음
    더보기
    프로필사진
    반응형
    • 분류 전체보기 (360)
      • report (4)
        • vulnhub (2)
        • tryhackme (2)
        • hackthebox (0)
      • write-up(web) (201)
        • misc (17)
        • dreamhack (91)
        • los (30)
        • webhacking.kr (63)
      • write-up(misc) (2)
        • dreamhack (2)
      • programming (89)
        • python (21)
        • php (8)
        • javascript (9)
        • sql (18)
        • c++ (9)
        • c (6)
        • web (17)
        • etc (1)
      • linux (19)
        • OverTheWire (8)
      • mac (11)
      • blockchain (14)
      • git (9)
      • security (11)
        • web (11)

    Copyright © Kakao Corp. All rights reserved.

    티스토리툴바