40823131 cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • about
  • Stage1
    • W1
      • 建立網頁
      • Blog建立
    • W2
      • 分組(二人專案小組)
      • 利用Hamachi建立虛擬區域網路
      • 利用虛擬主機建立Ethercalc伺服器
    • W3
      • 初代機(version 1.0.0) ฅ^•ω•^ฅ
      • 貳代機(version 2.0.0) ^ↀᴥↀ^
      • 参代機(version 3.0.0) ଲ(^ⓛ ω ⓛ^)ଲ
      • 肆代機(version 4.0.0) V(=^・ω・^=)v
    • W4
      • 利用程式方法更改影片檔名
  • Stage2
    • W5
      • 分組組員
    • W6
      • Heroku小組網站
      • 運輸小車繪製
    • W7
      • push more easily
      • 程式控制
    • W8
      • 使用鍵盤程式控制小車移動
    • W9
      • 成果(自動化生產線速率程式控制小車ver.)
      • 成果(自動化生產線鍵盤程式控制小車ver.)
      • 心得
  • Stage3
    • W10
      • task1
      • task2-1
    • W11
      • task2-2
    • W12
      • 直播教學影片
    • W13
      • task3-About OBS setting videos
      • Use aegisub to edit and generate subtitles
    • Final專案進度
  • W14
    • 使用QT based GUI介面改寫 legacy GUI介面
    • 改用 CoppeliaSim 制式的 Lua Script 編寫與原先取放方塊零件相同的操控流程
  • Basic teaching
    • Create SSH KEY
    • Setting up putty for ssh
    • Use Leo Editor to create a web blog
    • Android phone camera instead of webcam teaching
  • W15
  • W16
  • Github帳號解除Flagged過程分享
  • Python grammar sort out
W10 << Previous Next >> task2-1

task1

利用python程式讀取 stage3_2a.txt,建立 Stage3 的分組倉儲,分組網頁,以及各組員倉儲及網頁連結。

成果壓縮檔:task1.7z

講解影片:

程式碼(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

程式碼(version3)

新增各組員協同分組網站。

# open file, default is read mode, since txt content no chinese char
# no encoding = "UTF-8" is needed
with open("stage3_2a.txt") as fh:
    #開啟stage3_2a.txt檔案並命名為fh,並且使用with語法無需使用關閉語法cloce(),文件開啟後會自動關閉.
    data = fh.readlines()
    #讀取文件的每一行,直到遇到结束符 EOF.
    data = [a.replace('4823122','40823122') for a in data]
    #利用取代(replace)修正讀取出的錯誤學號.
    data = [c.replace('\t\t\t\t','') for c in data]
    #其中一組為六人,因此需消除列表中的多餘空格.
    #print(data)
#print(len(data))
for i in range(len(data)):
    #以range為len(data)=6進行迴圈,變數為i
    group = data[i].rstrip("\n").split("\t")
    #取data list中的第i項進行處理,去除元素中的\n,並利用\n為依據,分割元素成為新串列.
    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>')
    #使用print依序索引group list中的元素,放入html格式,並依序打印出來.

    for j in range(2,18,2):
    #以2為起始每次加2加到<18,也就是執行迴圈8次.
        #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>'+' | Group Website:'+'<a href="https://'+group[j]+'.github.io/stage3-ag'+group[0][9]+'">'+group[j]+'</a></p>')
    #依序索引group list中的元素放入html格式,並打印出來.
        except:
            continue
    #有一組為六人,因此此處會出現out of range錯誤,需使用try...except語法解決.
#try...except語法為若try下方敘述執行錯誤,則執行except下方敘述,此處我需要迴圈繼續,因此使用continue.

程式碼(version4)

# 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,並且使用with語法無需使用關閉語法cloce(),文件開啟後會自動關閉.
    data = fh.readlines()
    #讀取文件的每一行,直到遇到结束符 EOF.
    data = [a.replace('4823122','40823122') for a in data]
    #利用取代(replace)修正讀取出的錯誤學號.
    data = [c.replace('\t\t\t\t','') for c in data]
    #其中一組為六人,因此需消除列表中的多餘空格.
    data = [b.replace('_','-') for b in data]
    #將_取代為-,以便後續存取.
    #print(data)
#print(len(data))
for i in range(len(data)):
    group = data[i].rstrip("\n").split("\t")
    #print(group)
    print('<p>'+group[0]+' | <a href="https://'+group[1]+'.github.io/stage3-ag'+group[0]+'">網站</a> | <a href="https://github.com/'+group[2]+'/'+group[0]+'">倉儲</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>'+' | Group Website:'+'<a href="https://'+group[j]+'.github.io/'+group[0]+'">'+group[j]+'</a></p>')
        except:
            continue
 #有一組為六人,因此此處會出現out of range錯誤,需使用try...except語法解決.
#try...except語法為若try下方敘述執行錯誤,則執行except下方敘述,此處我需要迴圈繼續,因此使用continue.            
            

成果:

stage3-ag1 | 網站 | 倉儲

40823131 | Website:40823131 | Repository:40823131 | Group Website:40823131

a40823112 | Website:a40823112 | Repository:a40823112 | Group Website:a40823112

40823123 | Website:40823123 | Repository:40823123 | Group Website:40823123

40823145 | Website:40823145 | Repository:40823145 | Group Website:40823145

40823136 | Website:40823136 | Repository:40823136 | Group Website:40823136

40823109 | Website:40823109 | Repository:40823109 | Group Website:40823109

40823116 | Website:40823116 | Repository:40823116 | Group Website:40823116

40823108 | Website:40823108 | Repository:40823108 | Group Website:40823108

stage3-ag2 | 網站 | 倉儲

40823151 | Website:40823151 | Repository:40823151 | Group Website:40823151

40623121 | Website:40623121 | Repository:40623121 | Group Website:40623121

40871106 | Website:40871106 | Repository:40871106 | Group Website:40871106

40823102 | Website:40823102 | Repository:40823102 | Group Website:40823102

40823104 | Website:40823104 | Repository:40823104 | Group Website:40823104

40823106 | Website:40823106 | Repository:40823106 | Group Website:40823106

40823101 | Website:40823101 | Repository:40823101 | Group Website:40823101

40823132 | Website:40823132 | Repository:40823132 | Group Website:40823132

stage3-ag3 | 網站 | 倉儲

40823119 | Website:40823119 | Repository:40823119 | Group Website:40823119

40823150 | Website:40823150 | Repository:40823150 | Group Website:40823150

40823103 | Website:40823103 | Repository:40823103 | Group Website:40823103

40823107 | Website:40823107 | Repository:40823107 | Group Website:40823107

40523252 | Website:40523252 | Repository:40523252 | Group Website:40523252

40823154 | Website:40823154 | Repository:40823154 | Group Website:40823154

stage3-ag4 | 網站 | 倉儲

40823142 | Website:40823142 | Repository:40823142 | Group Website:40823142

40823144 | Website:40823144 | Repository:40823144 | Group Website:40823144

40823127 | Website:40823127 | Repository:40823127 | Group Website:40823127

40823148 | Website:40823148 | Repository:40823148 | Group Website:40823148

40823121 | Website:40823121 | Repository:40823121 | Group Website:40823121

40823135 | Website:40823135 | Repository:40823135 | Group Website:40823135

40823114 | Website:40823114 | Repository:40823114 | Group Website:40823114

40823146 | Website:40823146 | Repository:40823146 | Group Website:40823146

stage3-ag5 | 網站 | 倉儲

40823111 | Website:40823111 | Repository:40823111 | Group Website:40823111

40823115 | Website:40823115 | Repository:40823115 | Group Website:40823115

40823128 | Website:40823128 | Repository:40823128 | Group Website:40823128

40823120 | Website:40823120 | Repository:40823120 | Group Website:40823120

40823140 | Website:40823140 | Repository:40823140 | Group Website:40823140

40823124 | Website:40823124 | Repository:40823124 | Group Website:40823124

40823139 | Website:40823139 | Repository:40823139 | Group Website:40823139

40823126 | Website:40823126 | Repository:40823126 | Group Website:40823126

stage3-ag6 | 網站 | 倉儲

40823152 | Website:40823152 | Repository:40823152 | Group Website:40823152

40823110 | Website:40823110 | Repository:40823110 | Group Website:40823110

40823122 | Website:40823122 | Repository:40823122 | Group Website:40823122

40823125 | Website:40823125 | Repository:40823125 | Group Website:40823125

40823117 | Website:40823117 | Repository:40823117 | Group Website:40823117

40823129 | Website:40823129 | Repository:40823129 | Group Website:40823129

40823149 | Website:40823149 | Repository:40823149 | Group Website:40823149

40823153 | Website:40823153 | Repository:40823153 | Group Website:40823153


W10 << Previous Next >> task2-1

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