40823135 zeray

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • w1
  • w2
  • w3
  • w4
  • w5
  • w6
  • w7
  • w8
  • w9
  • stage3
    • w10
    • w11-12
    • w13-14
    • w15-16
    • w17-18
    • task
  • robotdk
  • 動力學
    • 畢氏
    • 代數
  • 16-exam
w17-18 << Previous Next >> robotdk

task

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
with open("stage3_2a.txt") as fh:
#先將我們存起來stage3_2a.txt打開並命名為fh
data = fh.readlines()
#將stage3_2a.txt的資料以串列形式存為data
for i in range(6):
#將次數限定就不會告知list index out of range了
newdata1 = data[i].replace('4823122','40823122')
#因為40823122的學號打錯了,所以用 replace 把舊的替換成新的
newdata2 = newdata1.replace('\t\t','')
#因為有一組只有6人,所以用 replace 把空位刪除
newdata3 = newdata2.replace('_','-')
#因為在編輯txt的時候-會變成_,所以用 replace 把_修正為-
group = newdata3.rstrip("\n").split("\t")
#先取出newdata list中的第i項,消除元素中/n,再以\t取出需要的文字
print('<p><a href="https://github.com/'+group[1]+'/'+group[0]+'">'+group[0]+' repo</a> | <a href="https://'+group[2]+'.github.io/'+group[0]+'">'+group[0]+' site</a></p>')
for j in range(1,18,2):
#設一個範圍,(1到18,每次+2,1<=j<18)
try:
n = group[j].replace('40823112','a40823112')
#因為40823112的github帳號是a40823112,所以用 replace 把帳號修正
print('<p>'+'<a href="https://github.com/'+n+'/cd2021">'+group[j]+' repo</a> | <a href="https://'+n+'.github.io/cd2021">'+group[j]+' site</a></p>')
except:
continue
#這邊使用try.....except,因為有一組6個人,導致有空格,所以需要用continue讓迴圈繼續跑

結果 : 

stage3-ag1 repo | stage3-ag1 site

40823131 repo | 40823131 site

40823112 repo | 40823112 site

40823123 repo | 40823123 site

40823145 repo | 40823145 site

40823136 repo | 40823136 site

40823109 repo | 40823109 site

40823116 repo | 40823116 site

40823108 repo | 40823108 site

stage3-ag2 repo | stage3-ag2 site

40823151 repo | 40823151 site

40623121 repo | 40623121 site

40871106 repo | 40871106 site

40823102 repo | 40823102 site

40823104 repo | 40823104 site

40823106 repo | 40823106 site

40823101 repo | 40823101 site

40823132 repo | 40823132 site

stage3-ag3 repo | stage3-ag3 site

40823119 repo | 40823119 site

40823150 repo | 40823150 site

40823103 repo | 40823103 site

40823107 repo | 40823107 site

40523252 repo | 40523252 site

40823154 repo | 40823154 site

stage3-ag4 repo | stage3-ag4 site

40823142 repo | 40823142 site

40823144 repo | 40823144 site

40823127 repo | 40823127 site

40823148 repo | 40823148 site

40823121 repo | 40823121 site

40823135 repo | 40823135 site

40823114 repo | 40823114 site

40823146 repo | 40823146 site

stage3-ag5 repo | stage3-ag5 site

40823111 repo | 40823111 site

40823115 repo | 40823115 site

40823128 repo | 40823128 site

40823120 repo | 40823120 site

40823140 repo | 40823140 site

40823124 repo | 40823124 site

40823139 repo | 40823139 site

40823126 repo | 40823126 site

stage3-ag6 repo | stage3-ag6 site

40823152 repo | 40823152 site

40823110 repo | 40823110 site

40823122 repo | 40823122 site

40823125 repo | 40823125 site

40823117 repo | 40823117 site

40823129 repo | 40823129 site

40823149 repo | 40823149 site

40823153 repo | 40823153 site


w17-18 << Previous Next >> robotdk

Copyright © All rights reserved | This template is made with by Colorlib