小組會議 <<
Previous Next >> task2
task1
參考40823131的task1
# open file, default is read mode, since txt content no chinese char4
# no encoding = "UTF-08" is needed
with open("stage3_2a.txt") as fh: #打開"stage3_2a.txt檔案並命名為fh
# readlines will read into the whole line and put into list format 23
# has \n at the end of each line 13
#讀取 fh檔案並當作data
data = fh.readlines()
#修改錯誤的學號
data = [a.replace('4823122','40823122') for a in data]
#去除組別空白部分
data = [b.replace('\t\t\t\t','') for b in data]
#print(data)#印出data
#print(len(data))
for i in range(len(data)):#設i迴圈的次數為data的長度
#print(data)
group = data[i].rstrip("\n").split("\t")#設group為取data的次數i消除\n並且以\t分割數列
#print(group)
print('<p>'+group[0]+' _ <a href="https://'+group[1]+'.github.io/'+group[0]+'">site</a> | <a href="https://github.com/'+group[1]+'/'+group[0]+'">repo</a></p>')
#印出group字串
for g in range(2,18,2):#設g迴圈的範圍從第3項開始+2到第18項
try:#try...except 可跳過讀取不到的資料
print('<p>'+group[g]+'_site:'+'<a href="https://'+group[g]+'.github.io/cd2021'+'">'+group[g]+'</a>'+'|repo:'+'<a href="https://github.com/'+group[g]+'/cd2021'+'">'+group[g]+'</a></p>')
#印出group字串
except:
continue#返回迴圈
小組會議 <<
Previous Next >> task2