W10 <<
Previous task1
利用python程式讀取 stage3_2a.txt,建立 Stage3 的分組倉儲,分組網頁,以及各組員倉儲及網頁連結。
講解影片:
程式碼(version1)
# 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:
# readlines will read into the whole line and put into list format 23
# has \n at the end of each line 13
data = fh.readlines()
#print(len(data))1
for i in range(len(data)):
group = data[i].rstrip("\n").split("\t")
print('<p>'+group[0]+'|<a href="https://'+group[1]+'.github.io/stage3-ag'+group[0][9]+'">網站</a>|<a href="https://github.com/'+group[2]+'/stage3-ag'+group[0][9]+'">倉儲</a></p>')
for j in range(2,18,2):
print('<p>'+group[j]+'|Website:'+'<a href="https://'+group[j]+'.github.io/cd2021'+'">'+group[j]+'</a>'+'|Repository:'+'<a href="https://github.com/'+group[j]+'/cd2021'+'">'+group[j]+'</a></p>')
程式碼(version2)
# 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:
# readlines will read into the whole line and put into list format 23
# has \n at the end of each line 13
data = fh.readlines()
data = [a.replace('4823122','40823122') for a in data]
data = [c.replace('\t\t\t\t','') for c in data]
print(data)
#print(len(data))1
for i in range(len(data)):
group = data[i].rstrip("\n").split("\t")
print('<p>'+group[0]+'|<a href="https://'+group[1]+'.github.io/stage3-ag'+group[0][9]+'">網站</a>|<a href="https://github.com/'+group[2]+'/stage3-ag'+group[0][9]+'">倉儲</a></p>')
# the following will use group data to generate needed html
for j in range(2,18,2):
try:
print('<p>'+group[j]+'|Website:'+'<a href="https://'+group[j]+'.github.io/cd2021'+'">'+group[j]+'</a>'+'|Repository:'+'<a href="https://github.com/'+group[j]+'/cd2021'+'">'+group[j]+'</a></p>')
except:
continue
stage3_ag1 | 網站 | 倉儲
40823131 | Website:40823131 | Repository:40823131
a40823112 | Website:a40823112 | Repository:a40823112
40823123 | Website:40823123 | Repository:40823123
40823145 | Website:40823145 | Repository:40823145
40823136 | Website:40823136 | Repository:40823136
40823109 | Website:40823109 | Repository:40823109
40823116 | Website:40823116 | Repository:40823116
40823108 | Website:40823108 | Repository:40823108
stage3_ag2 | 網站 | 倉儲
40823151 | Website:40823151 | Repository:40823151
40623121 | Website:40623121 | Repository:40623121
40871106 | Website:40871106 | Repository:40871106
40823102 | Website:40823102 | Repository:40823102
40823104 | Website:40823104 | Repository:40823104
40823106 | Website:40823106 | Repository:40823106
40823101 | Website:40823101 | Repository:40823101
40823132 | Website:40823132 | Repository:40823132
stage3_ag3 | 網站 | 倉儲
40823119 | Website:40823119 | Repository:40823119
40823150 | Website:40823150 | Repository:40823150
40823103 | Website:40823103 | Repository:40823103
40823107 | Website:40823107 | Repository:40823107
40523252 | Website:40523252 | Repository:40523252
40823154 | Website:40823154 | Repository:40823154
stage3_ag4 | 網站 | 倉儲
40823142 | Website:40823142 | Repository:40823142
40823144 | Website:40823144 | Repository:40823144
40823127 | Website:40823127 | Repository:40823127
40823148 | Website:40823148 | Repository:40823148
40823121 | Website:40823121 | Repository:40823121
40823135 | Website:40823135 | Repository:40823135
40823114 | Website:40823114 | Repository:40823114
40823146 | Website:40823146 | Repository:40823146
stage3_ag5 | 網站 | 倉儲
40823111 | Website:40823111 | Repository:40823111
40823115 | Website:40823115 | Repository:40823115
40823128 | Website:40823128 | Repository:40823128
40823120 | Website:40823120 | Repository:40823120
40823140 | Website:40823140 | Repository:40823140
40823124 | Website:40823124 | Repository:40823124
40823139 | Website:40823139 | Repository:40823139
40823126 | Website:40823126 | Repository:40823126
stage3_ag6 | 網站 | 倉儲
40823152 | Website:40823152 | Repository:40823152
40823110 | Website:40823110 | Repository:40823110
40823122 | Website:40823122 | Repository:40823122
40823125 | Website:40823125 | Repository:40823125
40823117 | Website:40823117 | Repository:40823117
40823129 | Website:40823129 | Repository:40823129
40823149 | Website:40823149 | Repository:40823149
40823153 | Website:40823153 | Repository:40823153
W10 <<
Previous