|
发表于 2021-9-4 13:25:38
|
显示全部楼层
本帖最后由 傻眼貓咪 于 2021-9-4 14:26 编辑
代碼:
- limit = 16
- caps = [i for i in range(65, 91)]+[i for i in range(97, 123)]
- digits = [i for i in range(48, 58)]
- symbols = [i for i in range(33, 48)]+[i for i in range(58, 65)]+[91, 92, 93, 94, 95, 96, 123, 124, 125]
- def check(p: 'passwords') -> bool:
- if len(p) < limit:
- return False
- elif ord(p[0]) not in caps:
- return False
- return (any([bool(ord(i) in caps) for i in p])\
- and any([bool(ord(i) in digits) for i in p])\
- and any([bool(ord(i) in symbols) for i in p]))
- print(check(input('請輸入密碼:\n')))
复制代码
輸入/輸出結果:
- 請輸入密碼:
- fsdfdsf5643564354%^$^&%%*HGFDFJ
- True
- 請輸入密碼:
- &*%abc
- False
复制代码 |
|