python 正則匹配
阿新 • • 發佈:2021-06-16
正則匹配
- 題目描述:
現公司要開發一個業務管理系統,要求註冊環節的密碼需要提示使用者其安全等級,密碼按如下規則進行計分,並根據不同的得分為密碼進行安全等級劃分;此外,密碼的組成可以由字母,數字,以及符號構成。
以下為密碼分數判斷選項,每項判斷只能拿一個分項:
-
密碼長度:
- 5 分: 小於等於4個字元
- 10 分: 5到7字元
- 25 分: 大於等於8個字元
-
字母:
- 0 分: 沒有字母
- 10 分: 全都是小(大)寫字母
- 20 分: 大小寫混合字母
-
數字:
- 0 分: 沒有數字
- 10 分: 1個數字
- 20 分: 大於1個數字
-
符號:
- 0 分: 沒有符號
- 10 分: 1個符號
- 25 分: 大於1個符號
-
獎勵:
- 2 分: 字母和數字
- 3 分: 字母、數字和符號
- 5 分: 大小寫字母、數字和符號
最後的評分標準:
大於等於90: 非常安全
大於等於80: 安全
大於等於70: 非常強
大於等於 60: 強
大於等於 50: 一般
大於等於 25: 弱
大於等於0: 非常弱
當用戶輸入一個密碼字串後,判斷密碼等級,並輸出
輸入描述:
1
|
|
輸出:
1
|
|
程式碼實現如下:
1
|
|