Coursera Chaptereight:Lists Assignment 8.5
来源:互联网 发布:网络药理学会议 编辑:程序博客网 时间:2024/06/05 18:54
8.5 Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line:
From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a count at the end.
Hint: make sure not to include the lines that start with 'From:'.
You can download the sample data athttp://www.pythonlearn.com/code/mbox-short.txt
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"fh = open(fname)
count = 0
for line in fh:
line=line.rstrip()
if not line.startswith('From '):continue
w=line.split()
print w[1]
count=count+1
print "There were", count, "lines in the file with From as the first word"
0 0
- Coursera Chaptereight:Lists Assignment 8.5
- Coursera Chaptereight:Lists Assignment 8.4
- Coursera机器学习 week6 assignment
- Coursera机器学习 week7 assignment
- Coursera机器学习 week8 assignment
- Coursera机器学习 week2 assignment
- Coursera机器学习 week3 assignment
- Coursera机器学习 week4 assignment
- Coursera机器学习 week9 assignment
- Coursera Scala 4-7:Lists
- coursera算法课 Programming Assignment 1:Percolation
- Coursera Algorithms Programming Assignment 1: Percolation
- Coursera Algorithm class programming assignment 1——Percolation
- Coursera机器学习 week5 神经网络的学习 assignment
- Coursera Algorithms Programming Assignment 2: Deque and Randomized Queue
- Coursera Scala 5-5 List:Reduction of Lists
- Assignment
- Coursera
- oracle性能调优-执行计划
- 初始化job,并分析svn日志--initNEW1-UFT.bat
- 从尾到头打印链表
- 学习笔记之深入浅出MFC 第4章 对话框的运行
- Windows系统下IE单双多进程分析
- Coursera Chaptereight:Lists Assignment 8.5
- Java 自定义异常类
- iOS开发之指定UIView的某几个角为圆角
- Java enum的用法详解
- 让多个 DIV 高度相同
- 网络管理 -- TCP/IP协议簇
- Error:Connection timed out:connect.
- netstat 命令详解
- phyton3.5 django典型错误