|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
020讲的动动手第1题,链接如下:
第020讲:函数:内嵌函数和闭包 | 课后测试题及答案
http://bbs.fishc.com/thread-42685-1-1.html
(出处: 鱼C论坛)
小甲鱼老师的答案运行后的结果又内容:ilovefishc
而我的答案运行后,返回的是空值;
以下是我的代码,请帮忙看看
str1 = '''小甲鱼老师的字符串内容'''
for i in str1:
if i.islower(): #如果i 是小写字母
tuple1 = str1.partition(i) #将str1分成三个部分的元祖
if len(tuple1[0]) > 3 and len(tuple1[2]) >3: #如果第一段和第三段的元祖的长度都大于3
if tuple1[0][-3:].isupper() and tuple1[2][:3].isupper() and tuple1[0][-4].isupper() is False and tuple1[2][3].isupper() is False:
print(i)
elif len(tuple1[0]) == 3 and len(tuple1[2]) >3: #如果第一段长度等于3,,第三段的元祖的长度大于3
if tuple1[0][-3:].isupper() and tuple1[2][:3].isupper() and tuple1[2][3].isupper() is False:
print(i)
elif len(tuple1[0]) > 3 and len(tuple1[2]) == 3: #如果第一段长度大于3,,第三段的元祖的长度等于3
if tuple1[0][-3:].isupper() and tuple1[2][:3].isupper() and tuple1[0][-4].isupper() is False:
print(i)
elif len(tuple1[0]) == 3 and len(tuple1[2]) ==3: #如果第一段和第三段的元祖的长度都等于3
if tuple1[0][-3:].isupper() and tuple1[2][:3].isupper():
print(i)
else:
print('没有找到符合条件的密码')
break
|
|