class Financial:
def __init__(self, number, q, a, b, c, d, ans):
self.number, self.q, self.ans = number, q, ans
self.a, self.b, self.c, self.d = a, b, c, d
f = open('C:/Users/user/Downloads/金融常識.txt','r',encoding='utf-8')
read = f.readlines() #read = f.read()
f.close()
List = []
Answer=(4,4,3,4,3,2,3,3,4,2,4,4,4,3,4,2,3,1,1,2,1,2,3,3,1,3,4,4,3,4,1,4,3,2,4,2,2,3,2,4,1,4,1,1,4,3,1,2,4,1,2,1,4,4,4,1,4,2,1,3,3,1,4,4,3,2,2,2,4,4,1,3,3,1,2,4,1,3,4,4,2,4,4,3,4,1,3,2,3,2,3,2,2,2,4,4,4,1,1,2,2,4,4,1,4,1,4,4,4,2,1,1,2,1,2,1,2,2,3,3,3,4,2,1,1,1,1,2,2,1,4,4,4,4,4,4,4,3,4,4,1,1,2,2,3,4,4,3,1,4,2,3,3,2,1,3,4,4,2,4,1,1,3,3,2,2,3,1,2,1,4,3,3,2,2,2,1,4,2,4,3,3,3,1,3,3,2,3,3,1,4,4,3,2,4,2,2,4,1,1,1,3,1,3,2,2,3,4,4,3,2,2,1,2,4,1,1,2,2,1,1,1,3,1,2,2,2,1,1,4,1,3,1,1,1,1,1,3,1,2,3,3,3,2,4,3,3,3,1,2,4,2,3,3,1,4,2,3,3,3,4,1,2,3,2,3,4,2,3,4,4,1,2,4,3,4,4,2,2,3,1,4,3,4,2,1,2,3,2,4,2,1,3,4,1,2,1,1,4,1,2,4,1,4,3,4,4,2,2,1,1,2,3,4,3,3,1,3,1,4,4,3,2,4,4,2,1,1,4,1,1,2,3,2,3,3,4,2,2,4,3,3,3,2,1,1,2,2,4,1,4,1,3,1,1,4,1,4,4,3,1,4,3,3,2,1,1,4,2,4,2,4,1,1,4,1,3,1,2,4,1,1,4,1,3,1,3,4,1,4,2,3,1,3,2,3,3,3,4,2,3,4,3,1,4,1,3,3,4,4,4,4,1,2,3,1,3,3,3,1,3,4,1,3,1,4,1,3,2,4,4,3,1,1,4,2,1,3,1,2,2,1,1,4,3,2,3,4,1,4,1,1,4,2,1,2,1,2,4,3,1,3,3,2,4,3,1,2,1,3,3,3,1,4,3,1,3,2,3,1,3,1,4,1,1,4,4,2,3,1,4,4,3,4,1,3,4,2,3,4,4,2,3,1)
nList, nAnswer = len(read), len(Answer)
if nList != nAnswer: print('題目長度 ', nList, ' 與答案長度 ', nAnswer,' 不同!')
for i in range( nList ):
a1 = read[i].find('(1)')
b2 = read[i].find('(2)')
c3 = read[i].find('(3)')
d4 = read[i].find('(4)')
q = read[i][:a1]#一次修改區塊shift+alt
a = read[i][a1 + 3 : b2]
b = read[i][b2 + 3 : c3]
c = read[i][c3 + 3 : d4]
d = read[i][d4 + 3 : -1]
List.append( Financial( i+1, q, a, b, c, d, str(Answer[i])) )
outputList = []
title = '
超級帥老猴Python撰寫金融常識測驗網頁
' style ='' javascript = '' outputList.append(style) outputList.append(javascript) outputList.append(title) outputList.append('- ')
tmp0 = "
- \n"
tmp3 = "
- \n
- " tmp5 = " \n
- " tmp6 = "
"
for i in range(nList): #range(nList)
tmp = tmp0 + List[i].ans + tmp1 + str(List[i].number).zfill(3) + tmp2
tmp += List[i].q + tmp3 + str(List[i].number).zfill(3) + tmp4
tmp += List[i].a + tmp5
tmp += List[i].b + tmp5
tmp += List[i].c + tmp5
tmp += List[i].d + tmp6
outputList.append(tmp)
outputList.append('
https://quyznn07.blogspot.com/2025/10/class-financial-def-initself-number-q-b.html
回覆刪除