小米笔试第一题,请大佬看看这样对不对。
import re def check_password(): res = [] try: list2 = input().split(' ') for i in range(len(list2)): each = list2[i] if len(each) < 8 or len(each) > 120: res.append('1') elif re.match("^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])).*$", each) == None: res.append('2') else: res.append('0') result=print('\n'.join(res)) return result except EOFError: return if __name__=='__main__': check_password()#笔试题目##小米#