
範例輸入/輸出:

code:
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 19 00:29:15 2023
@author: SavingKing
"""
def chk(strr):
strr_5 = strr[:-1]
#'12345'
lis_int = [eval(i) for i in strr_5]
s0 = lis_int[0]
s2 = lis_int[2]
s4 = lis_int[4]
s1 = lis_int[1]
s3 = lis_int[3]
result = ((s0+s2+s4)+(s1+s3)*5)%26
dic = {1:"A",
2:"B",
13:"M"}
if dic[result] == strr[-1]:
check = True
else:
check=False
return check
lis=[]
for i in range(3):
strr=input("請輸入學號:\t")
lis.append(strr)
"""
12345M
55237B
03805A
"""
for ele in lis:
if chk(ele):
print("Pass")
else:
print("Fail")輸出結果:

推薦hahow線上學習python: https://igrape.net/30afN





![Python爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件) Python爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/03/20250330190318_0_925655.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)


![Python: Regular Expression 正規表示法 正則表達式 import re ; pattn = “[\d]{4}\/[01][\d]\/[0123][\d] [\d]{6}” ; match = re .search (pattn,text) .group() Python: Regular Expression 正規表示法 正則表達式 import re ; pattn = “[\d]{4}\/[01][\d]\/[0123][\d] [\d]{6}” ; match = re .search (pattn,text) .group()](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2022/09/20220901154435_19.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言