name = input("Enter file:")
if len(name) < 1:
name = "mbox-short.txt"
handle = open(name)
didi = dict()
for line in handle:
line = line.rstrip()
if not line.startswith('From '):
continue
line = line.split()
line = line[1]
if not line in didi:
didi[line] = 1
else:
didi[line] += 1
be = None
bc = None
for email, count in didi.items():
if bc == None or bc < count:
be = email
bc = count
print(be, bc)
결과
'모두를 위한 Python 특화과정 > 20171047 김동훈' 카테고리의 다른 글
python 데이터 구조-5 (0) | 2022.08.03 |
---|---|
python 데이터 구조-3 (0) | 2022.07.27 |
python 데이터 구조-2 (0) | 2022.07.27 |
python 데이터 구조-1 (0) | 2022.07.19 |
Programming for Everybody (Getting Started with Python)-7 (0) | 2022.07.19 |