파이썬 - guardian , short circuit evaluation

Euisub Jung (Santa)·2021년 10월 30일
0

Python Data Structures - 예제 8.5

From 뒤의 메일주소를 추출하는 코드.

han = open('mbox-short.txt')

for line in han:
    line = line.rstrip()
    wds = line.split()

    # guardian in a compund statement
    # short circuit evaluation
    if len(wds) < 3 or wds[0] != 'From' :
        continue
    print(wds[1])
profile
오늘부터 개발자

0개의 댓글