
IT/파이썬 2021. 6. 11.
파이썬 - dictionary 처리 관련해서, empty check, 추가하기
리스트 말고 딕셔너리 dictionary 타입 처리는 어떻게? 맨날 헷갈려서 그냥 적어두자. 비어있는지 체크하는 방법은 아래와 같다. https://stackoverflow.com/questions/23177439/python-checking-if-a-dictionary-is-empty-doesnt-seem-to-work test_dict = {} if not test_dict: print "Dict is Empty" if not bool(test_dict): print "Dict is Empty" if len(test_dict) == 0: print "Dict is Empty" 아이템 추가는 https://www.kite.com/python/answers/how-to-append-a-value-to-a..
