我的大学里有一段文字,实际上是一封电子邮件:
FEDERAL UNIVERSITY OF ABC
Name : Rodrigo Martins de Oliveira
RA: 11009713
Campus : Campus Santo André
Shift: Morning
weekly charge
=============
Credit (T-P) : 18
Load - time (T-P-I) : 44
Requested enrollment in the following classes :
=================================
BC0208 - Mechanical Phenomenons A2-Morning (Santo André) - TPI (3-2-6) - Campus St. André
Tuesday from 10:00 to 12:00
Tuesday from 08:00 to 10:00
Thursday from 08:00 to 10:00
BC0504 - The Nature of Information A2-Morning (Santo André) - TPI (3-0-4) - Campus St. André
Friday from 08:00 to 10:00
Thursday from 10:00 to 12:00
BC0306 - Transformations in Living Beings and Environment A1-Morning (Santo André) - TPI (3-0-4) - Campus St. André
Wednesday from 08:00 to 10:00
Monday from 10:00 to 12:00
BC0402 - One Variable Functions A1-Morning (Santo André) - TPI (4-0-6) - Campus St. André
Monday from 08:00 to 10:00
Wednesday from 10:00 to 12:00
BC0404 - Analytic Geometry A2-Morning (Santo André) - TPI (3-0-6) - Campus St. André
Wednesday from 08:00 to 10:00
Friday from 10:00 to 12:00
Code of authenticity : 4TlG58kWtrdN1caEJM02Ik8/C01p + qLeSFDOtXHZLMJrafv3H/soML2XPkrU pBHmBXBwMgRbd7Y =
Note : Document for simple conference, follow in the site the results of this enrollment request.
-
This email was sent automatically on Thursday, September 19, 2013 , 12:06 . Please do not reply .
If there are any technical questions , please contact via email xxxxxx@yyyyy.zzz
这封电子邮件告诉我我要求报名的课程及其各自的时间表。我正在编写一个程序来自动获取此信息并创建一个像这样的表:
我刚刚开始编写这个程序,我需要获取类的代码(BC****
)及其各自的时间表,以便我绘制表格。
我该怎么做?
答案 0 :(得分:1)
根据新线分割线条,虽然这似乎是awk的工作!但是在python中
lst = text.split("\n")
#lst is of type list
for line in lst:
if lst[:2] == "BC":
#tadah, you know this line contains what you want do some magic
一个警告,可能是在BC部分之前有一些空间,所以撕掉额外的空间