标签:统计 NPU fail supper 枚举 用户登录 编写 seve 大写
# 打印每个o出现的位置 str1 = "hellopythonhelloworld" str2 = ‘hellopythonhelloworld‘ str3 = ‘hellopythonhelloworl‘ index = 0 for i in str1: if i == ‘o‘: print(index, end=‘\t‘) index += 1 # 枚举实现 str1 = ‘hellopythonhelloworl‘ for i, j in enumerate(list(str1)): if j == ‘o‘: print(i) # # 实现用户登录校验功能 # # 要求:分别提示用户输入用户名和密码,当用户名为seven,密码为123或用户名为alex密码为456时,显示登陆成功,并结束程序;否则显示登陆失败并提示用户重新输入用户名和密码. # # PS:用户只有3次登录校验的机会,第3次登录失败则结束程序。 # names = [‘alex‘, ‘seven‘] passwords = [‘123‘, ‘456‘] count = 1 while True: name = input(‘your name:‘) password = input(‘your password:‘) if name in names and password in passwords: print(‘wellcome log in‘) break else: print(‘fail to log please try again‘) count += 1 if count > 3: break # 编写函数,实现接收一个字符串,分别统计大写字母、小写字母、数字字符的个数。 str_a = "Java324javaajlsdf56sdfja54@vajav345aa234ddsfa987dsjkp132132jp324" count_number = 0 count_lower = 0 count_upper = 0 for i in range(0, len(str_a)): if str_a[i].isdigit(): count_number += 1 if str_a[i].islower(): count_lower += 1 if str_a[i].isupper(): count_upper += 1 print(‘数字有%d个‘ % (count_number)) print(‘小写字母有%d个‘ % (count_lower)) print(‘大写字母有%d个‘ % (count_upper))
标签:统计 NPU fail supper 枚举 用户登录 编写 seve 大写
原文地址:https://www.cnblogs.com/teark/p/14247961.html