Python 사전에 키가 있는지 확인
키가 사전에 존재하는지 확인
지정된 키가 사전에 있는지 확인하려면 다음 in
키워드 를 사용하십시오.
예시
사전에 "model"이 있는지 확인하십시오.
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
if "model" in thisdict:
print("Yes, 'model' is
one of the keys in the thisdict dictionary")