Keyword Arguments

๊ฑฐ๋ถ์ดยท2023๋…„ 3์›” 18์ผ
0

๐Ÿ“ŒKeyword Arguments

def say_hello(name, age):
  print(f"Hello {name} you are {age} years old")

# positional : ์ž๋ฆฌ๊ฐ€ ์ •ํ•ด์ ธ์žˆ๋Š” ๊ฒฝ์šฐ
# ์ž๋ฆฌ์˜ ์ˆœ์„œ๋ฅผ ๊ณ ๋ คํ•œ ์ƒํƒœ์ธ๋ฐ ๊ทธ ์ˆœ์„œ๋ฅผ ๊ณ ๋ คํ•˜์ง€์•Š์€๊ฑฐ๋ผ๋ฉด Error๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.
say_hello("nico", 12)
# ์ž๋ฆฌ์— ๋Œ€ํ•ด ์‹ ๊ฒฝ์“ฐ์ง€ ์•Š๋Š” ๋Œ€์‹ ์— argument์— ์ดˆ์ ์„ ๋งž์ถ”๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์“ธ ์ˆ˜ ์žˆ๋‹ค.
say_hello(age=12, name="nico")
# get : ์›น ์‚ฌ์ดํŠธ๋ฅผ ๋ฐ›์•„์˜ค๋Š” ๋ฐฉ
from requests import get
from bs4 import BeautifulSoup

base_URL = "https://weworkremotely.com/remote-jobs/search?term"
search_term = "Python"

# ๋ฌธ์ž์—ด ์•ˆ์— ๋ณ€์ˆ˜๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ๋Š” f๋ฅผ ์‚ฌ์šฉ
response = get(f"{base_URL}{search_term}")
if response.status_code != 200:
  print("Can't request website")
else:
  Soup = BeautifulSoup(response.text, "html.parser")
  print(Soup.find_all("section", class_="jobs"))

# class_ : class๋ผ๋Š” keyword๊ฐ€ ์ด๋ฏธ Python์—์„œ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ

0๊ฐœ์˜ ๋Œ“๊ธ€