# Use words.txt as the file name
fname = input("Input file name : ")
fh = open('words.txt')
for line in fh:
line = line.rstrip()
print(line.upper())
결과
# Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
abc=0
count=0
for line in fh:
if not line.startswith("X-DSPAM-Confidence:"):
continue
line= line.split()
line=line[1]
abc+=float(line)
count+=1
#print(abc)
print('Average spam confidence:',abc/count)
결과
'모두를 위한 Python 특화과정 > 20171047 김동훈' 카테고리의 다른 글
python 데이터 구조-4 (0) | 2022.08.03 |
---|---|
python 데이터 구조-3 (0) | 2022.07.27 |
python 데이터 구조-1 (0) | 2022.07.19 |
Programming for Everybody (Getting Started with Python)-7 (0) | 2022.07.19 |
Programming for Everybody (Getting Started with Python)-6 (0) | 2022.07.19 |