code = {
'A':"10",
'B':"11",
'C':"12",
'D':"13",
'E':"14",
'F':"15",
'G':"16",
'H':"17",
'I':"34",
'J':"18",
'K':"19",
'M':"21",
'N':"22",
'O':"35",
'P':"23",
'Q':"24",
'T':"27",
'U':"28",
'V':"29",
'W':"32",
'X':"30",
'Z':"33",
}
weight = [1,9,8,7,6,5,4,3,2,1,1] # 權重
ID = input("請輸入身份證字號:")
nList = []
nList.append(code[ID[0]][0])
nList.append(code[ID[0]][1])
for char in ID[1:]:
nList.append(char)
s = 0 # 加總分
for i in range(len(nList)):
s += int(nList[i]) * weight[i]
if s % 10 == 0:
print("身分證字號合法")
else:
print("身份證字號不合法")
原本電腦中的設定有多個python macOS內建python3、有透過brew、IDLE、PyCharm安裝的 https://developer.apple.com/forums/thread/680222 後來全都都刪除 /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 /usr/local/ bin/python3 /usr/bin/python3
Aug 24, 2022松崗 作者黃建庭 2-15 bit位移 A = 5 << 2 2-16 運算子優先順序 1 ()[]{}
Aug 7, 2021def function 要先定義,定義完要呼叫才會執行 def test(): print("123") test() 因為python是直譯的關係,如果先呼叫 會找不到定義
Jul 28, 2021List 陣列、串列 list是有序的 string = "String" for s in string: print(s) # "String" => "S","t","r","i","n","g" Tuple 元組
Jul 12, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up