[レコーダなし]Pythonを使用したWebスクリプト-Day 3の作成
6437 ワード
1.9 Conditionals part One
📝 if - else
# 문법
if CONDITION:
...
else:
...
# 예시
def plus(a, b):
if type(b) is int or type(b) is float:
return a + b
else:
return None
plus(12, "10")
1.10 if else and or
x or y
:両方ともtruex and y
:両方ともtruenot x
:xはfalseでなければならない# 예시
def age_check(age):
print(f"you are {age}")
if age < 18:
print("you can't drink")
elif age == 18:
print("you are new to this!")
elif age > 20 and age < 25:
print("you are still kind of young")
else:
print("enjoy your drink")
age_check(18)
age_check(23)
# 결과
you are 18
you are new to this!
you are 23
you are still kind of young
1.11 for in
📝 for loop
# 문법
for 변수명 in 배열:
body
ex)
days
(O), [1, 2, 3, 4, 5]
(O) # 예시
days = {"Mon", "Tue", "Wed", "Thu", "Fri"}
for day in days:
if day is "Wed":
break
else:
print(x)
# 결과
Mon
Tue
Wed
day
break
Reference
この問題について([レコーダなし]Pythonを使用したWebスクリプト-Day 3の作成), 我々は、より多くの情報をここで見つけました https://velog.io/@yu-jin-song/노마드코더-Python으로-웹-스크래퍼-만들기-Day-3テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol