withopen("2a raw.txt")as fh: rea = fh.readlines()#print (rea)no_list =lambdalist: int((sum([(len(list[i])) for i inrange(len(list))]))/3)#簡寫一個for迴圈命名為no_list,目的為求出迴圈執行次數(14次)t =list()#命名空清單tfor k inrange(len(rea)): a = rea[k] b = a.split()#分割每一行第k位#print(b)for i inrange(0,len(b),3): c = b[i:i+3]#每三字串為一次進行迴圈 t.append(c)#加入清單tfor g inrange(no_list(t)):#range = 14print("第"+str(g+1) +"組:"+str(t[g]))
<script type="text/javascript" src="https://cdn.rawgit.com/brython-dev/brython/3.4.0/www/src/brython.js"></script><body onload="brython()"><div id="one"><script type="text/python">{% raw %}from browser import document, htmlimport time@document["mybutton"].bind("click")defecho(ev): fake_qs ='?foo=%s'%time.time()withopen("./../../../../2a.txt"+fake_qs)as fh: rea = fh.readlines()#print (rea) no_list =lambdalist: int((sum([(len(list[i])) for i inrange(len(list))]))/3)#簡寫一個for迴圈命名為no_list,目的為求出迴圈執行次數(14次) t =list()#命名空清單tfor k inrange(len(rea)): a = rea[k] b = a.split()#分割每一行第k位#print(b)for i inrange(0,len(b),3): c = b[i:i+3]#每三字串為一次進行迴圈 t.append(c)#加入清單tfor g inrange(no_list(t)):#range = 14 document["one"]<= ("第"+str(g+1)+"組:"+str(t[g])) + html.BR()@document["mybutton2"].bind("click")defdelete(ev):for row in document['one']: row.remove(){% endraw %}</script></div><button id="mybutton">執行</button><button id="mybutton2">清除</button></body>