Guidelines

ν•¨μˆ˜ μ†μ˜ ν•¨μˆ˜, 콜백 ν•¨μˆ˜

콜백 ν•¨μˆ˜λž€ ν•˜λ‚˜μ˜ ν•¨μˆ˜λ₯Ό λ‹€λ₯Έ ν•¨μˆ˜μ˜ λ§€κ°œλ³€μˆ˜λ‘œ μ „λ‹¬ν•˜μ—¬, κ·Έ ν•¨μˆ˜ λ‚΄μ—μ„œ ν˜ΈμΆœλ˜λŠ” ν•¨μˆ˜λ₯Ό μ˜λ―Έν•©λ‹ˆλ‹€.

μ½œλ°±μ€ 비동기 ν”„λ‘œκ·Έλž˜λ°, 이벀트 처리, λ˜λŠ” νŠΉμ • 쑰건이 μΆ©μ‘±λ˜μ—ˆμ„ λ•Œ μΆ”κ°€ λ™μž‘μ„ μˆ˜ν–‰ν•  λ•Œ 주둜 μ‚¬μš©λ©λ‹ˆλ‹€.


콜백 ν•¨μˆ˜ ν™œμš©

콜백 ν•¨μˆ˜λ₯Ό ν™œμš©ν•˜λ©΄ ν•¨μˆ˜λ₯Ό λ§€κ°œλ³€μˆ˜λ‘œ μ „λ‹¬ν•˜κ³  ν•¨μˆ˜ λ‚΄μ—μ„œ μ „λ‹¬ν•œ ν•¨μˆ˜λ₯Ό ν˜ΈμΆœν•¨μœΌλ‘œμ¨, λ‹€μ–‘ν•œ λ™μž‘μ„ λ™μ μœΌλ‘œ μ‹€ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

콜백 ν•¨μˆ˜ μ˜ˆμ‹œ
def greeting(name): return f"μ•ˆλ…•ν•˜μ„Έμš”, {name}λ‹˜!" def process_user_input(callback): # 콜백 ν•¨μˆ˜λ₯Ό λ§€κ°œλ³€μˆ˜λ‘œ 전달 name = input("이름을 μž…λ ₯ν•˜μ„Έμš”: ") # μ‚¬μš©μž μž…λ ₯ print(callback(name)) # 전달받은 ν•¨μˆ˜ 호좜 process_user_input(greeting)

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result